当前位置: 代码迷 >> Java Web开发 >> 求大家帮帮忙,我是个初学JSP的新手
  详细解决方案

求大家帮帮忙,我是个初学JSP的新手

热度:379   发布时间:2007-04-08 15:13:58.0
求大家帮帮忙,我是个初学JSP的新手

各位朋友,我是个初学jsp的新手,请各位帮帮忙,我用JCreator执行这个servlet总会有很多的错误,执行别的servlet也会有类似的错误,谁能给我解释一下阿!代码如下:
package test;
  import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  public class Test extends HttpServlet {
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
  PrintWriter out=response.getWriter();
  out.println("<html><body><h1>This is a servlet test.</h1></body></html>");
  out.flush();
  }
  }
错误如下:
C:\test\Test.java:2: illegal character: \12288
  import java.io.IOException;
^
C:\test\Test.java:2: illegal character: \12288
  import java.io.IOException;
^
C:\test\Test.java:3: illegal character: \12288
  import java.io.PrintWriter;
^
C:\test\Test.java:3: illegal character: \12288
  import java.io.PrintWriter;
^
C:\test\Test.java:4: illegal character: \12288
  import javax.servlet.ServletException;
^
C:\test\Test.java:4: illegal character: \12288
  import javax.servlet.ServletException;
^
C:\test\Test.java:5: illegal character: \12288
  import javax.servlet.http.HttpServlet;
^
C:\test\Test.java:5: illegal character: \12288
  import javax.servlet.http.HttpServlet;
^
C:\test\Test.java:6: illegal character: \12288
  import javax.servlet.http.HttpServletRequest;
^
C:\test\Test.java:6: illegal character: \12288
  import javax.servlet.http.HttpServletRequest;
^
C:\test\Test.java:7: illegal character: \12288
  import javax.servlet.http.HttpServletResponse;

^
C:\test\Test.java:7: illegal character: \12288
  import javax.servlet.http.HttpServletResponse;
^
C:\test\Test.java:8: illegal character: \12288
  public class Test extends HttpServlet
^
C:\test\Test.java:8: illegal character: \12288
  public class Test extends HttpServlet
^
C:\test\Test.java:10: illegal character: \12288
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
C:\test\Test.java:10: illegal character: \12288
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
^
C:\test\Test.java:11: illegal character: \12288
  throws ServletException, IOException
^
C:\test\Test.java:11: illegal character: \12288
  throws ServletException, IOException
^
C:\test\Test.java:13: illegal character: \12288
  PrintWriter out=response.getWriter();
^
C:\test\Test.java:13: illegal character: \12288
  PrintWriter out=response.getWriter();
^
C:\test\Test.java:14: illegal character: \12288
  out.println("<html><body><h1>This is a servlet test.</h1></body></html>");
^
C:\test\Test.java:14: illegal character: \12288
  out.println("<html><body><h1>This is a servlet test.</h1></body></html>");
^
C:\test\Test.java:15: illegal character: \12288
  out.flush();
^
C:\test\Test.java:15: illegal character: \12288
  out.flush();
^
C:\test\Test.java:16: illegal character: \12288
  }
^
C:\test\Test.java:16: illegal character: \12288
  }
^
C:\test\Test.java:17: illegal character: \12288
 }
^
C:\test\Test.java:17: <identifier> expected
 }
^
28 errors

搜索更多相关主题的帖子: JSP  初学  

----------------解决方案--------------------------------------------------------
建议你换个IDE,jc一开始还可以,现在写 servlet了,用用jbuilder 或是 eclipse ...啥的就行了

代码应该没错

----------------解决方案--------------------------------------------------------
非法字符!!
----------------解决方案--------------------------------------------------------
jCreater ,即使你设置了环境变量,好像也里面识别不了servlet API包
----------------解决方案--------------------------------------------------------
有可能是你的JDK的问题  我用的也是JCREATER 编写SERVLET一点问题也没有  
----------------解决方案--------------------------------------------------------
谢谢各位~~~~
----------------解决方案--------------------------------------------------------
  相关解决方案