?
Solved

straightforward set attribute error

Posted on 2003-03-26
4
Medium Priority
?
188 Views
Last Modified: 2010-04-01
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
Comment
Question by:jhazard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:javaexpert
ID: 8209319
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
 
LVL 7

Accepted Solution

by:
damonf earned 80 total points
ID: 8210083
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
 
LVL 19

Expert Comment

by:cheekycj
ID: 8211030
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
 
LVL 14

Expert Comment

by:kennethxu
ID: 8211034
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question