Session check.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Yurik_Siva
Posted On:   Tuesday, November 13, 2001 07:44 PM

Hi, I tried to use this code in my servlet: HttpSession session = request.getSession(false); if (session == null) { //redirect to login page } But if session doesn't exists I getting: Error: 500 Location: /WebTest/companysetup Internal Servlet Error: java.lang.NullPointerException at payroll.CompanySetup.doPost(CompanySetup.java:42) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.servic   More>>

Hi,


I tried to use this code in my servlet:

			

HttpSession session = request.getSession(false);
if (session == null)
{
//redirect to login page
}




But if session doesn't exists I getting:
			

Error: 500
Location: /WebTest/companysetup
Internal Servlet Error:

java.lang.NullPointerException
at payroll.CompanySetup.doPost(CompanySetup.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
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.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
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:484)



What could be the ptoblem?

Thanks.
   <<Less

Re: Session check.

Posted By:   Pedro_Jimenez  
Posted On:   Wednesday, November 14, 2001 02:11 AM

Please check in your java file
CompanySetup.java in the line 42 is possible that you use a reference to a null object.

If HttpSession doesn't exists, you can't uses methods of the interface HttpSession in the session object.

I think that there's the problem.


Regards

Re: Session check.

Posted By:   Naveed_Azhar  
Posted On:   Wednesday, November 14, 2001 12:21 AM

Please make sure that you are not calling a method of any null object ( or null session object )

naveed@hotmail.com
About | Sitemap | Contact