jsp - org.apache.jasper.JasperException: java.lang.NullPointerException error -
error:
type exception report
messageinternal server error
descriptionthe server encountered internal error prevented fulfilling request.
exception
org.apache.jasper.jasperexception: java.lang.nullpointerexception root cause
java.lang.nullpointerexception note full stack traces of exception , root causes available in glassfish server open source edition 4.1 logs.
emailconfirmation.jsp
<%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>dentistree</title> <link rel="stylesheet" type="text/css" href="emailconfirmation.css"> </head> <body> <button id="home" onmouseover="h1()" onmouseout="h2()"><b>home</b></button> <button id="register" onmouseover="r1()" onmouseout="r2()"><b>register</b></button> <button id="login" onmouseover="l1()" onmouseout="l2()"><b>login</b></button> <button id="appointment" onmouseover="a1()" onmouseout="a2()"><b>appointment</b></button> <button id="map" onmouseover="m1()" onmouseout="m2()"><b>map</b></button> <button id="report" onmouseover="re1()" onmouseout="re2()"><b>report</b></button> <button id="doctor" onmouseover="d1()" onmouseout="d2()"><b>doctor</b></button> <%@page import="javax.mail.passwordauthentication"%> <%@page import="java.util.properties"%> <%@page import="javax.mail.message"%> <%@page import="javax.mail.messagingexception"%> <%@page import="javax.mail.session"%> <%@page import="javax.mail.transport"%> <%@page import="javax.mail.internet.internetaddress"%> <%@page import="javax.mail.internet.mimemessage"%> <% string name = request.getparameter("nmtxt"); string pwd = request.getparameter("passtxt"); string date = request.getparameter("txtdate"); string address = request.getparameter("txtadd"); string blood = request.getparameter("bloodgrp"); string sex= request.getparameter("sex"); string email=request.getparameter("emailaddtxt"); final string username="a@.com"; final string password="an"; stringbuffer sb=new stringbuffer(); for(int i=0;i<5;i++) { sb.append((char)(int)(math.random()*79+23+7)); } string cap=new string(sb); properties props=new properties(); props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); props.put("mail.smtp.auth", true); props.put("mail.smtp.starttls.enable", true); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.port", "587"); string emailtxt1=request.getparameter("emailaddtxt"); session ses=session.getinstance(props,new javax.mail.authenticator() { protected passwordauthentication getpasswordauthentication() { return new passwordauthentication(username, password); } }); try { message message=new mimemessage(ses); message.setfrom(new internetaddress("a@.com")); message.setrecipients(message.recipienttype.to,internetaddress.parse(emailtxt1)); message.setcontent("<body>"+"hi "+name+".<br>"+"you have signed dentistree through email id:<b>"+emailtxt1+"</b><br>your password is:<b>"+pwd+"</b>thanks registering dentistree.your unique identification number is<b></br>"+cap+"</b></body>","text/html"); transport.send(message); } catch(messagingexception e) { throw new runtimeexception(e); } %> <%@ page import ="java.sql.*" %> <% class.forname("com.mysql.jdbc.driver"); connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/dentistree","root", "tiger"); statement st = con.createstatement(); //resultset rs; string s="insert patient(name,password, birthdate, address, gender,email,unique_key,bloodgroup) values ("+"'"+name+"','"+ pwd+ "','" + date + "','" + address + "','" + sex + "','" + email +"','" + cap + "','" + blood+"')"; try { int = st.executeupdate(s); } catch(exception e) { out.print(e); } session.setattribute("mail", email); %> <div id="maindiv"> <h1 id="title"><b>dentistree</b></h1> <h3 id="congo" align="center"><b>congratulations!!!</b></h3> <form name="mailconfo" action="confirm.jsp"> <pre id="para"> you've created dentistree account. you're account activation step away. email has been sent email address.it consist of unique dentistree key.enter key in textfield below activate account</pre> <label id='uniquekey'><b>enter unique key:</b></label> <input type='text' id='uniquekeytxt' name="uniquekeytxt" required> <input type="submit" value="submit" id="sub"> <form name="mailconfo" action="confirm.jsp"> </div> </body>
confirm.jsp
<%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>dentistree</title> <link rel="stylesheet" type="text/css" href="confirm.css"> </head> <body> <button id="home" onmouseover="h1()" onmouseout="h2()"><b>home</b></button> <button id="register" onmouseover="r1()" onmouseout="r2()"><b>register</b> </button> <button id="login" onmouseover="l1()" onmouseout="l2()"><b>login</b></button> <button id="appointment" onmouseover="a1()" onmouseout="a2()"><b>appointment</b></button> <button id="map" onmouseover="m1()" onmouseout="m2()"><b>map</b></button> <button id="report" onmouseover="re1()" onmouseout="re2()"><b>report</b></button> <button id="doctor" onmouseover="d1()" onmouseout="d2()"><b>doctor</b></button> <div id="maindiv"> <h1 id="title"><b>dentistree</b></h1> <%@ page import ="java.sql.*" %> <form name="mailconfo"> <% string conf=request.getparameter("uniquekeytxt"); string mail=session.getattribute("mail").tostring(); class.forname("com.mysql.jdbc.driver"); connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/dentistree", "root", "tiger"); statement st = con.createstatement(); resultset rs = st.executequery("select unique_key patient email='"+mail+"'"); string s="update patient set verified='yes' email='"+mail+"'"; try{ if(conf.equals(rs)) { try { int = st.executeupdate(s); } catch(exception e) { out.print(e); } out.print("<h3 align='center'><b>congratulations!!!</b></h1>"); out.print("<p>your account has been verified</p>"); out.print("<p>click on login login account</p>"); } else { response.sendredirect("emailconfirmation.jsp"); }} catch(exception e) { out.print(e); } %> </form> </div> </body> </html>
error occuring in confirm.jsp. checked , both mail , uniquekeytxt have data in them.
include code in try catch block can idea.
try { string mail=session.getattribute("mail").tostring(); } catch(nullpointerexception e){}
Comments
Post a Comment