Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

straightforward set attribute error

mycode: (by a process of elimination I know it is the postcode line that is causing the error but I don't know why)....

session.setAttribute("Title",vTitle);
session.setAttribute("FirstName",vFirstName);
session.setAttribute("Surname",vSurname);
session.setAttribute("House",vHouseNo);    
session.setAttribute("Postcode2",vPostcode2);    
session.setAttribute("UserName",vUserName);
session.setAttribute("Password",vPassword);    

my error:
Location: /checkdetails.jsp
Internal Servlet Error:

java.lang.NullPointerException
     at java.util.Hashtable.put(Hashtable.java:389)
     at org.apache.tomcat.session.StandardSession.setAttribute(StandardSession.java:731)
     at _0002fcheckdetails_0002ejspcheckdetails_jsp_49._jspService(_0002fcheckdetails_0002ejspcheckdetails_jsp_49.java:117)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
     at org.apache.tomcat.core.Handler.service(Handler.java:287)
     at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
     at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
     at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
     at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java:160)
     at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
     at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
     at java.lang.Thread.run(Thread.java:536)

Root cause:
java.lang.NullPointerException
     at java.util.Hashtable.put(Hashtable.java:389)
     at org.apache.tomcat.session.StandardSession.setAttribute(StandardSession.java:731)
     at _0002fcheckdetails_0002ejspcheckdetails_jsp_49._jspService(_0002fcheckdetails_0002ejspcheckdetails_jsp_49.java:117)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
     at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
     at org.apache.tomcat.core.Handler.service(Handler.java:287)
     at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
     at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
     at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
     at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java:160)
     at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
     at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
     at java.lang.Thread.run(Thread.java:536)

0
jhazard
Asked:
jhazard
1 Solution
 
javaexpertCommented:
Looks like the problem is in line 49 of your jsp file.  What is that line?

Maybe do a System.out.println() of the object in reference in line 49.

Hope that helps.
0
 
damonfCommented:
vPostcode2 is null.  The session objects are backed by Hashtables, and you cannot put a null value or key into a hashtable.  I can't see the line where you set the value of vPostcode2, but if you're doing something like this:

vPostcode2 = request.getParameter("postcodewhatever");

and "postcodewhatever" doesn't really exist (for example you misspelled it), then vPostcode2 will be null.  If the field does exist in the form but is blank, vPostcode2 will be empty string (not null).
0
 
cheekycjCommented:
could you tell us what line 117 in your (_0002fcheckdetails_0002ejspcheckdetails_jsp_49.java file is?  This file should be in your work directory.

CJ
0
 
kennethxuCommented:
I agree with damonf. if you are sure the postcode line gives you problem then it must because it is null. it's NOTHING to do with the line 49 of your jsp file.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now