错误:
         cn.com.jbaptech.javaoraprj.faqtool.CommandException: AddCommand:No Driver Available!
cn.com.jbaptech.javaoraprj.faqtool.AddCommand.execute(AddCommand.java:35)
cn.com.jbaptech.javaoraprj.faqtool.FaqAdminServlet.service(FaqAdminServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

解决方案 »

  1.   

    javax.servlet.http.HttpServlet在servlet-api.jar
      

  2.   

    那怎样将它导入到工程里面?我用的是myeclipse
      

  3.   

    这是运行环境中的包,不需要导入到 classpath 中的。
      

  4.   

    那我这是什么错啊
    错误:
      at cn.com.jbaptech.javaoraprj.faqtool.AddCommand.execute(AddCommand.java:35)
    at cn.com.jbaptech.javaoraprj.faqtool.FaqAdminServlet.service(FaqAdminServlet.java:25)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)AddCommand.java代码:
    package cn.com.jbaptech.javaoraprj.faqtool;import javax.servlet.*;
    import javax.servlet.http.*;public class AddCommand implements Command {
      private String next;  public AddCommand(String next) {
        this.next = next;
      }  public String execute(HttpServletRequest req)
        throws CommandException {
        try {
          if (CommandToken.isValid(req)) {
    FaqRepository faqs = FaqRepository.getInstance();
    FaqBean faq = new FaqBean();
    faq.setQuestion(req.getParameter("question"));
    faq.setAnswer(req.getParameter("answer"));
    faqs.put(faq);
    req.setAttribute("faqtool.msg", "FAQ Added Successfully");
          }
          else {
    req.setAttribute("faqtool.msg", "Invalid Reload Attempted");
          }
          return next;
        }
        catch (FaqRepositoryException fe) {
          throw new CommandException("AddCommand: " + fe.getMessage());
        }
      }
    }FaqAdminServlet.java代码:
    package cn.com.jbaptech.javaoraprj.faqtool;import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServlet.*;
    import java.util.*;public class FaqAdminServlet extends HttpServlet {
      private HashMap commands;
      private String error = "error.jsp";
      private String jspdir = "/faqtool/";  public void init(ServletConfig config) throws ServletException {
        super.init(config);
        initCommands();
      }  public void service(HttpServletRequest req,
          HttpServletResponse res)
        throws ServletException, IOException {
        String next;
        try {
          Command cmd = lookupCommand(req.getParameter("cmd"));
          next = cmd.execute(req);
          CommandToken.set(req);
        }
        catch (CommandException e) {
          req.setAttribute("javax.servlet.jsp.jspException", e);
          next = error;
        }
        RequestDispatcher rd;
        rd = getServletContext().getRequestDispatcher(jspdir + next);
        rd.forward(req, res);
      }  private Command lookupCommand(String cmd)
        throws CommandException {
        if (cmd == null)
          cmd = "main-menu";
        if (commands.containsKey(cmd.toLowerCase()))
          return (Command)commands.get(cmd.toLowerCase());
        else
          throw new CommandException("Invalid Command Identifier");
      }  private void initCommands() {
        commands = new HashMap();
        commands.put("main-menu", new NullCommand("menu.jsp"));
        commands.put("abort", new AbortCommand("menu.jsp"));
        commands.put("add", new NullCommand("add.jsp"));
        commands.put("do-add", new AddCommand("menu.jsp"));
        commands.put("update-menu", new GetAllCommand("upd_menu.jsp"));
        commands.put("update", new GetCommand("update.jsp"));
        commands.put("do-update", new UpdateCommand("menu.jsp"));
        commands.put("delete-menu", new GetAllCommand("del_menu.jsp"));
        commands.put("delete", new GetCommand("delete.jsp"));
        commands.put("do-delete", new DeleteCommand("menu.jsp"));
      }
    }求救!!!!!!!!!!!!!
      

  5.   

    还有个错误:
    cn.com.jbaptech.javaoraprj.faqtool.CommandException: AddCommand:No Driver Available!
      

  6.   

    这个方法的错    35行错了public String execute(HttpServletRequest req)
      throws CommandException {
      try {
      if (CommandToken.isValid(req)) {
    FaqRepository faqs = FaqRepository.getInstance();
    FaqBean faq = new FaqBean();
    faq.setQuestion(req.getParameter("question"));
    faq.setAnswer(req.getParameter("answer"));
    faqs.put(faq);
    req.setAttribute("faqtool.msg", "FAQ Added Successfully");
      }
      else {
    req.setAttribute("faqtool.msg", "Invalid Reload Attempted");
      }
      return next;
      }
      catch (FaqRepositoryException fe) {
      throw new CommandException("AddCommand: " + fe.getMessage());
      }
      }
    }
      

  7.   

    就这个方法错了   你自己找找吧  

    public String execute(HttpServletRequest req)throws CommandException {
    异常信息写的啊 没有有效的驱动
      

  8.   

    很少用MyEclipse,一般都tomcat+Eclipse,那个jar在tomcat下就有,看看你的 部署环境吧
      

  9.   

    tomcat要部署环境吗?我以前还都没部署过
      

  10.   

    可以把你TOMCAT 解压开的common/lib目录下的servlet-API jar 复制到项目里