MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » jsp页面异常 大家帮看看是程序有关问题还是配置有关

jsp页面异常 大家帮看看是程序有关问题还是配置有关问题

www.MyException.Cn  网友分享于:2013-09-12  浏览:7次
jsp页面错误 大家帮看看是程序问题还是配置问题
我照网上的源码写了个数据库测试jsp页面
   <%@ 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= "1983 ";
   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>


----------------------------
我的tomcat5.0   ,sqlserver打的sp4的补丁,3个jdbc都放在了common/lib下,我把这个jsp文件放在了ROOT/下,运行就出现了这样的错误:
HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:520)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

java.io.UTFDataFormatException:   Invalid   byte   1   of   1-byte   UTF-8   sequence.
org.apache.jasper.xmlparser.UTF8Reader.invalidByte(UTF8Reader.java:615)
org.apache.jasper.xmlparser.UTF8Reader.read(UTF8Reader.java:487)
org.apache.jasper.xmlparser.XercesEncodingDetector.load(XercesEncodingDetector.java:1000)
org.apache.jasper.xmlparser.XercesEncodingDetector.skipString(XercesEncodingDetector.java:951)
org.apache.jasper.xmlparser.XercesEncodingDetector.scanXMLDecl(XercesEncodingDetector.java:1209)
org.apache.jasper.xmlparser.XercesEncodingDetector.getEncoding(XercesEncodingDetector.java:108)
org.apache.jasper.xmlparser.XercesEncodingDetector.getEncodingMethod(XercesEncodingDetector.java:121)
org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:57)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:313)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:170)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有