编写的jsp文件无法连接上SQL2000数据库,找了很多资料,也已经按照http://java.chinaitlab.com/ServletJsp/30404.html 上所说的去解决了,但是还是报错,内容如下:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /testsql.jsp(1,4) Invalid directive
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause ..............我弄了2天了,确实找不问题来了,东西都重装过了,就差系统没重装了,麻烦高手看看啊,这里先谢谢了!~

解决方案 »

  1.   

    <%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %>
      <html>
      <body>
      <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
      String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
      //pubs 为你的数据库的
      String user="sa";
      String password="";
      Connection conn= DriverManager.getConnection(url,user,password);
      Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
      String sql="select job_id,job_desc from jobs";
      ResultSet rs=stmt.executeQuery(sql);
      while(rs.next()) { %>
      您的第一个字段内容为:<%=rs.getString(1)%><br>
      您的第二个字段内容为:<%=rs.getString(2)%><br>
      <% } %>
      <% out.print("数据库操作成功,恭喜你"); %>
      <% rs.close();
      stmt.close();
      conn.close();
      %>
      </body>
      </html>
    这个是我用来测试的程序代码
    我的系统变量是Path=C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;D:\jdk1.5.0_06\bin;
    classpath=.;D:\jdk1.5.0_06\lib\dt.jar;D:\jdk1.5.0_06\lib\tools.jar;D:\Tomcat 5.5
    \common\lib\servlet.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JD
    BC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib
    \mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\
    msutil.jar;
    放在D:\Tomcat 5.5\webapps\ROOT   运行报错为
    HTTP Status 404 - /ROOT/testsql.jsp--------------------------------------------------------------------------------type Status reportmessage /ROOT/testsql.jspdescription The requested resource (/ROOT/testsql.jsp) is not available.放在D:\Tomcat 5.5\webapps\myapp  运行报错为HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /testsql.jsp(1,4) Invalid directive
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause org.apache.jasper.JasperException: /testsql.jsp(1,4) Invalid directive
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:515)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
    org.apache.jasper.compiler.Parser.parse(Parser.java:126)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.电脑配置:windows Server 2003 sp1
             JDK1.5
             Tomcat 5.5
             SQL2000 sp3 
      

  2.   

    tomcat启动后,你直接http://localhost:8080可以显示JSP默认主页吗?如果可以的话,msbase.jar,mssqlserver.jar,msutil.jar有没有拷贝到Tomcat目录下common\lib目录下
      

  3.   

    tomcat启动后能正常显示JSP的默认主页,msbase.jar,mssqlserver.jar,msutil.jar也已经拷贝到Tomcat目录下common\lib目录下了
      

  4.   

    tomcat关闭以后再重新启动不可以吗?
      

  5.   

    tomcat关闭了在重新启动也不行,但是我刚刚把测试代码放在JBuilder里,报了一堆错!~