在安装jsp环境配置软件时,jdk和tomcat均以测试配置成功,打开网页运行jsp时出现
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
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
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.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:126)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 的错误,查询了下可能是数据库连接出现问题。又不知道怎么调,请问下高手该怎么解决问题啊 令附上tomcat work下index_jsp.java:
package org.apache.jsp;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent { private static java.util.Vector _jspx_dependants; public java.util.List getDependants() {
return _jspx_dependants;
} public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException { JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out; out.write("\r\n");
out.write("\r\n");
com.lyc.db.Conn con = null;
synchronized (_jspx_page_context) {
con = (com.lyc.db.Conn) _jspx_page_context.getAttribute("con", PageContext.PAGE_SCOPE);
if (con == null){
con = new com.lyc.db.Conn();
_jspx_page_context.setAttribute("con", con, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<link href=\"css/default.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
out.write("<title></title>\r\n");
out.write("<style type=\"text/css\">\r\n");
out.write("<!--\r\n");
out.write("body {\r\n");
out.write("\tbackground-image: url();\r\n");
out.write("}\r\n");
out.write("-->\r\n");
out.write("</style></head>\r\n");
out.write("<body>\r\n");
out.write("<table width=\"1006\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"27\" colspan=\"3\" align=\"right\"> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td width=\"1\" height=\"36\" background=\"SO01871_.wmf\"></td>\r\n");
out.write(" <td width=\"1004\"><div id=\"link1\" style=\"width: 870; height: 19\"><a href=\"student/index.jsp\">学生注册</a> \r\n");
out.write(" <a href=\"teacher/index.jsp\">教师注册</a></div></td>\r\n");
out.write(" <td width=\"1\" background=\"images/gbnavr.gif\"></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolorlight=\"#FFFFFF\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"50\" bgcolor=\"#FFFFFF\"><div id=\"top\" style=\"width: 624; height: 43\"> \r\n");
out.write(" <font face=\"华文行楷\" color=\"#008080\" size=\"6\">学生成绩管理系统</font></div></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" height=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"100%\" valign=\"top\" bgcolor=\"#FFFFFF\">\r\n");
out.write(" <img border=\"0\" src=\"images/bg2.JPG\" width=\"750\" height=\"500\">\r\n");
out.write(" </td>\r\n");
out.write(" <td width=\"180\" rowspan=\"2\" valign=\"top\" bgcolor=\"#F5f7f7\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\" colspan=\"2\" align=\"center\" background=\"images/tdbg.jpg\"><div id=\"font1\">登录入口</div></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <form name=\"form1\" method=\"post\" action=\"login.jsp\"><tr>\r\n");
out.write(" <td width=\"37%\" height=\"22\" align=\"center\">学号:</td>\r\n");
out.write(" <td width=\"63%\">\r\n");
out.write(" <input name=\"username\" type=\"text\" size=\"12\"> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\" align=\"center\">密 码:</td>\r\n");
out.write(" <td height=\"22\"><input name=\"password\" type=\"password\" size=\"12\"></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\">\r\n");
out.write(" <td height=\"30\" colspan=\"2\">\r\n");
out.write(" <input name=\"select\" type=\"radio\" value=\"student\" checked >\r\n");
out.write(" 学生\r\n");
out.write(" <input name=\"select\" type=\"radio\" value=\"teacher\">\r\n");
out.write(" 教师</td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\">\r\n");
out.write(" <td height=\"30\" colspan=\"2\">\r\n");
out.write(" <input type=\"submit\" name=\"Submit2\" value=\"进入\">\r\n");
out.write(" \r\n");
out.write("<input name=\"Submit\" type=\"reset\" value=\"重置\"></td>\r\n");
out.write(" </tr></form>\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write("<tr>\r\n");
out.write(" <td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"images/tdbg.jpg\" >\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"27\"><div id=\"font1\">友情链接</div></td>\r\n");
out.write(" </tr>\r\n");ResultSet rs=con.getRs("SELECT address,name FROM tblink");
while(rs.next()){ out.write("\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\"><div id=\"link2\"><a href=\"");
out.print(rs.getString(1));
out.write("\" target=\"_blank\">");
out.print(rs.getString(2));
out.write("</a></div></td>\r\n");
out.write(" </tr>\r\n"); }
con.close(); out.write("\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" height=\"50\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"1\"bgcolor=\"#FFFFFF\"><hr size=\"1\" color=\"#CC3300\" style=\"position:absolute;\"></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td bgcolor=\"#FFFFFF\"> <a href=\"[email protected]\">联系本站</a> |<a href=\"admin\\index.htm\">系统管理员</a> | ©2007 \r\n");
out.write(" xztccomputer </td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
有高手帮忙解决下,最好留下qq细谈,或加本人qq739275264,不胜感激
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
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
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.lang.NullPointerException
org.apache.jsp.index_jsp._jspService(index_jsp.java:126)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 的错误,查询了下可能是数据库连接出现问题。又不知道怎么调,请问下高手该怎么解决问题啊 令附上tomcat work下index_jsp.java:
package org.apache.jsp;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent { private static java.util.Vector _jspx_dependants; public java.util.List getDependants() {
return _jspx_dependants;
} public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException { JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out; out.write("\r\n");
out.write("\r\n");
com.lyc.db.Conn con = null;
synchronized (_jspx_page_context) {
con = (com.lyc.db.Conn) _jspx_page_context.getAttribute("con", PageContext.PAGE_SCOPE);
if (con == null){
con = new com.lyc.db.Conn();
_jspx_page_context.setAttribute("con", con, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<link href=\"css/default.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
out.write("<title></title>\r\n");
out.write("<style type=\"text/css\">\r\n");
out.write("<!--\r\n");
out.write("body {\r\n");
out.write("\tbackground-image: url();\r\n");
out.write("}\r\n");
out.write("-->\r\n");
out.write("</style></head>\r\n");
out.write("<body>\r\n");
out.write("<table width=\"1006\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"27\" colspan=\"3\" align=\"right\"> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td width=\"1\" height=\"36\" background=\"SO01871_.wmf\"></td>\r\n");
out.write(" <td width=\"1004\"><div id=\"link1\" style=\"width: 870; height: 19\"><a href=\"student/index.jsp\">学生注册</a> \r\n");
out.write(" <a href=\"teacher/index.jsp\">教师注册</a></div></td>\r\n");
out.write(" <td width=\"1\" background=\"images/gbnavr.gif\"></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bordercolorlight=\"#FFFFFF\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"50\" bgcolor=\"#FFFFFF\"><div id=\"top\" style=\"width: 624; height: 43\"> \r\n");
out.write(" <font face=\"华文行楷\" color=\"#008080\" size=\"6\">学生成绩管理系统</font></div></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" height=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"100%\" valign=\"top\" bgcolor=\"#FFFFFF\">\r\n");
out.write(" <img border=\"0\" src=\"images/bg2.JPG\" width=\"750\" height=\"500\">\r\n");
out.write(" </td>\r\n");
out.write(" <td width=\"180\" rowspan=\"2\" valign=\"top\" bgcolor=\"#F5f7f7\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\" colspan=\"2\" align=\"center\" background=\"images/tdbg.jpg\"><div id=\"font1\">登录入口</div></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <form name=\"form1\" method=\"post\" action=\"login.jsp\"><tr>\r\n");
out.write(" <td width=\"37%\" height=\"22\" align=\"center\">学号:</td>\r\n");
out.write(" <td width=\"63%\">\r\n");
out.write(" <input name=\"username\" type=\"text\" size=\"12\"> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\" align=\"center\">密 码:</td>\r\n");
out.write(" <td height=\"22\"><input name=\"password\" type=\"password\" size=\"12\"></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\">\r\n");
out.write(" <td height=\"30\" colspan=\"2\">\r\n");
out.write(" <input name=\"select\" type=\"radio\" value=\"student\" checked >\r\n");
out.write(" 学生\r\n");
out.write(" <input name=\"select\" type=\"radio\" value=\"teacher\">\r\n");
out.write(" 教师</td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr align=\"center\">\r\n");
out.write(" <td height=\"30\" colspan=\"2\">\r\n");
out.write(" <input type=\"submit\" name=\"Submit2\" value=\"进入\">\r\n");
out.write(" \r\n");
out.write("<input name=\"Submit\" type=\"reset\" value=\"重置\"></td>\r\n");
out.write(" </tr></form>\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write("<tr>\r\n");
out.write(" <td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"images/tdbg.jpg\" >\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"27\"><div id=\"font1\">友情链接</div></td>\r\n");
out.write(" </tr>\r\n");ResultSet rs=con.getRs("SELECT address,name FROM tblink");
while(rs.next()){ out.write("\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"22\"><div id=\"link2\"><a href=\"");
out.print(rs.getString(1));
out.write("\" target=\"_blank\">");
out.print(rs.getString(2));
out.write("</a></div></td>\r\n");
out.write(" </tr>\r\n"); }
con.close(); out.write("\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table></td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("<table width=\"100%\" height=\"50\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n");
out.write(" <tr>\r\n");
out.write(" <td height=\"1\"bgcolor=\"#FFFFFF\"><hr size=\"1\" color=\"#CC3300\" style=\"position:absolute;\"></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td bgcolor=\"#FFFFFF\"> <a href=\"[email protected]\">联系本站</a> |<a href=\"admin\\index.htm\">系统管理员</a> | ©2007 \r\n");
out.write(" xztccomputer </td>\r\n");
out.write(" </tr>\r\n");
out.write("</table>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
有高手帮忙解决下,最好留下qq细谈,或加本人qq739275264,不胜感激
用<%=>都好些
while(rs.next()){ 貌似是在这行出的错,你看看你获取的rs是否为空
肯定是getRs方法返回的是null了,你修改你的这个方法就可以啦