java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -


this question has answer here:

i have 4 pages on jsp web project student showing details db.. have used tomcat web server.

index.html

<body>     <h1> student search page</h1>     <form action="second.jsp">         <h2> enter id search details</h2>         <input type=text name=id1 /> <br/>         <input type=submit value=search />         </form> </body> 

second.jsp

<body>    <%    string id =(request.getparameter("id1"));    studentdao std=new studentdao();       student s=std.searchinfo("id");     %>    <h1> <%=s.showstudent()%></h1> </body> 

student.java

 import java.io.*;   public class student implements serializable {  string name;  string id1,phone,clas; student(string  id,string n,string c,string ph) {      name=n;      id1=id;      phone=ph;     clas=c; } public string showstudent() {    return  "name: "+name+" address: "+clas+" phone: "+phone+" id"+id1; } 

}

studentdao.java

import java.sql.*;  import java.io.*;   public class studentdao implements  serializable {  connection conn;     preparedstatement stmt;  public student searchinfo(string id) {     student studentinfo=null;  try{  string url="jdbc:ucanaccess://c:\\users\\asim iqbal\\documents\\student.accdb"; conn = drivermanager.getconnection(url); string sql= "select * studentdetails id=?";             stmt = conn.preparestatement(sql);             stmt.setstring(1,id);         } catch (sqlexception e) {             e.printstacktrace();         } resultset rs= null;         try {             rs = stmt.executequery();         } catch (sqlexception e1) {             e1.printstacktrace();         }         try {             while (rs.next())             {                string i=rs.getstring("id");                string nam=rs.getstring("name");                                  string ph=rs.getstring("phone");                string clas=rs.getstring("class");                 studentinfo=new student(i,nam,ph,clas);             }         } catch (sqlexception e1) {             e1.printstacktrace();         }         return studentinfo;  }   } 

this stacktrace , root cause..

stacktrace:

org.apache.jasper.servlet.jspservletwrapper.handlejspexception(jspservletwrapper.java:574)  org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:4  76) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:396)  org.apache.jasper.servlet.jspservlet.service(jspservlet.java:340)  javax.servlet.http.httpservlet.service(httpservlet.java:729) org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) 

root cause

 java.lang.nullpointerexception  student.studentdao.searchinfo(studentdao.java:35)  org.apache.jsp.second_jsp._jspservice(second_jsp.java:104)  org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70)  javax.servlet.http.httpservlet.service(httpservlet.java:729)  org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:438)  org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:396)  org.apache.jasper.servlet.jspservlet.service(jspservlet.java:340)  javax.servlet.http.httpservlet.service(httpservlet.java:729)  org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) 

note full stack trace of root cause available in apache tomcat/8.0.23 logs.

i not sure error facing.can paste error here can you.but seeing jsp page can there syntax error in following line " <%=s.showstudent()%>". give space between <%= , s.showstudent()%> ex: "<%= s.showstudent()%>"and try

can confirm able retrieve data db? student object null getting error think so

thanks,


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -