• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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...
 
Bartender
Posts: 2856
10
Firefox Browser Fedora 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.
 
Saloon Keeper
Posts: 22272
151
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic