日期:2014-05-18  浏览次数:20655 次

这个代码有什么错误呢?
package   mypack;
import   javax.servlet.*;
import   javax.servlet.http.*;
import   java.io.*;
import   java.util.*;
public   class   DispatchServlet   extends   HttpServlet{
      private   String   target= "/hello.jsp ";
      public   void   init(ServletConfig   config)
            throws   ServletException{
            super.init(config);
      }
      public   void   doGet(HttpServletRequest   request,
              HttpServletResponse   response)
        throws   ServletException,IOException{
      //If   it   is   a   get   request   forward   to   doPost()
      doPost(request,response);
      }
      public   void   doPost(HttpServletRequest   request,
              HttpServletResponse   response)
              throws   ServletException,IOException{
      //Get   the   username   from   the   request
      String   username=request.getParameter( "username ");
      //Get   the   password=request.getParamerer( "password ")
      String   password=request.getParameter( "password ");
      //Add   the   user   to   the   request
      request.setAttribute( "USER ",username);
      request.setAttribute( "PASSWORD ",password);
    //Forward   the   request   to   the   target   named
      ServletContext   context=getServletContext();
      System.out.println( "Redirecting   to   "+target);
      RequestDispatcher   dispatcher=
            context.getRequestDispatcher(target);
      dispatcher.forward(request,response);
    }  
  public   void   destroy(){
  }
}


在用javac编译时提示我     cannot   find   symbol.而且很多行都有这个错误,是为什么呢?

------解决方案--------------------
import javax.servlet.*;
import javax.servlet.http.*;

servlet包引入了没?
------解决方案--------------------
up
------解决方案--------------------
下班了,关注下
------解决方案--------------------
不要使用javac,使用jb,或者eclipse工具
------解决方案--------------------
推荐使用Netbeans 6 beta,特别是对于Java Web开发的新手,提供项目模板,自动部署等功能,很不多的,还集成了tomcat和glassfish v2