• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp error message 500 The server encountered an internal error that prevented it from fulfilling

 
reshma Ben
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a jsp page with data base connection while running it shows an error message like

HTTP Status 500 - An exception occurred processing JSP page /Save.jsp at line 28


type Exception report

message An exception occurred processing JSP page /Save.jsp at line 28

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

exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /Save.jsp at line 28

25: }
26: Statement stmt=null;
27: try{
28: stmt=con.createStatement();
29: }catch(SQLException e){
30: e.printStackTrace();
31: }


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)



root cause
java.lang.NullPointerException
org.apache.jsp.Save_jsp._jspService(Save_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)



note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.


Apache Tomcat/7.0.47

Please help...
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to CodeRanch .

When posting code, please make sure to UseCodeTags. It makes your code more readable.
As to answer your question, there is a null pointer exception on line 28. The only variable involved in that line is con. So it means con is null or not initialized prior to line 28.
Also it is a bad practice to add scriptlet code to JSP page. Use a servlet for the database part instead.
 
Tim Holloway
Bartender
Posts: 18414
58
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit Ghorpade wrote:
Also it is a bad practice to add scriptlet code to JSP page.


And this is one of the reasons why. It's a lot easier to debug java code errors if the code is in a java file than if it's in a JSP.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!