java - Client side data not displaying on webpage? -


when viewing ,view page source shows data.on webpage it's not rendering full data. this actually has thiswhile viewing view page source , 1 more when click delete shows meit throws exception new learning java servlet , new programming language also.i didn't get-tin on did mistake? don't know how prevent query string getting unnecessary value. please me on this?

<pre><code> package com.jspiders.studentsapp.servlets; import java.io.ioexception; import java.io.printwriter; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement;  import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;    import com.mysql.jdbc.driver;      public class viewallstudentdelete extends httpservlet {     protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception      {             resp.setcontenttype("text/html");             printwriter out=resp.getwriter();      system.out.println("mime type set");          connection con = null;         resultset rs = null;         statement stmt = null;          try {             driver driverref = new driver();             drivermanager.registerdriver(driverref);             string dburl = "jdbc:mysql://localhost:3306/becm145_db?user=root&password=root";             con = drivermanager.getconnection(dburl);              string query = "select * students_info si,students_otherinfo so,guardian_info gi"                     + " si.regno=so.regno , so.regno=gi.regno";              stmt = con.createstatement();             rs = stmt.executequery(query);               out.println("<html>"                          + "<body>"                   + "<table border=\"1\"width=\"100%\" >"                  +"<tr ><th>regno</th><th>first name</th><th>middle name</th><th>last name</th><th>is admin</th><th>password</th><th>gfirst name</th><th>gmiddle name</th><th>glast name</th><th>delete</th> </tr>");              while(rs.next())              {                  int regno=rs.getint("regno");//integer.parseint(req.getparameter("regno"));                 string fnm=rs.getstring("firstname");                    string mnm=rs.getstring("middlename");                    string lnm=rs.getstring("lastname");                    string admin=rs.getstring("isadmin");                    string passw=rs.getstring("password");                    string gfnm=rs.getstring("gfirstname");                    string gmnm=rs.getstring("gmiddlename");                    string glnm=rs.getstring("glastname");                     out.println("<tr><td>"                                + regno                              +"</td><td>"                              + fnm                              +"</td><td> "                              +mnm                              +"</td><td>"                              +lnm                              +"</td><td>"                              +admin                              +"</td><td>"                              +passw                              +"</td><td>"                              +gfnm                              +"</td><td>"                              +gmnm                              +"</td><td>"                              +glnm                              +"</td><td>"                              +"<a href=\"./deleteservlet?regno="                              +regno                              +" >delete</a></td></tr>");                           }             out.print("</table>"                  +"</body>"                       +"</html>");         } catch (exception e) {             e.printstacktrace();          } {             system.out.println("close jdbc objects");         }          try {             if (con != null) {                 con.close();             }             if (stmt != null) {                 stmt.close();              }             if (rs != null) {                 rs.close();              }         }          catch (sqlexception e) {             e.printstacktrace();         }      }      }  </pre></code> 

package com.jspiders.studentsapp.servlets;  import java.io.ioexception; import java.io.printwriter; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.preparedstatement;  import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;  import com.mysql.jdbc.driver; public class deleteservlet extends httpservlet {         protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception     {                 resp.setcontenttype("text/html");                 printwriter out=resp.getwriter();                 int regno=integer.parseint(req.getparameter("regno"));          system.out.println("mime type set");              connection con = null;             resultset rs = null;             preparedstatement pstmt = null;             preparedstatement pstmt1 = null;             preparedstatement pstmt2 = null;             int count,count1,count2 =0;             try {                 driver driverref = new driver();                 drivermanager.registerdriver(driverref);                 string dburl = "jdbc:mysql://localhost:3306/becm145_db?user=root&password=root";                 con = drivermanager.getconnection(dburl);                  string query = "delete students_info  regno=?";                  string query1 =   "delete students_otherinfo  regno=? ";               string query2=" delete guardian_info  regno=? ";//garbage collector call finalize before garbage collected when space full or reach level @ time garbage call finalize , collected                  pstmt = con.preparestatement(query);                 pstmt.setint(1,regno);                  count = pstmt.executeupdate();                 pstmt1 = con.preparestatement(query1);                 pstmt1.setint(1,regno);                 count1 = pstmt1.executeupdate();                 pstmt2 = con.preparestatement(query2);                 pstmt2.setint(1,regno);                 count2 = pstmt2.executeupdate();                 if(count == 1 && count1 == 1 && count2 == 1)                 {                     out.println("<h1>profile ,is deleted</h1>");                 }                 else                 {                     out.println("<h1>failed in deleting profile</h1>");                    }              } catch (exception e) {                 e.printstacktrace();              } {                 system.out.println("close jdbc objects");             }              try {                 if (con != null) {                     con.close();                 }                 if (pstmt != null) {                     pstmt.close();                  }                 if (rs != null) {                     rs.close();                  }             }              catch (sqlexception e) {                 e.printstacktrace();             }          }          } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -