I am creating a website using JSP and Servlets using Apache - tomcat 5.5 as server. My application runs fine. But whenever I leave any web page open and go back into it after a while say 30minutes, and then click any button or icon, it throws error sayin -

Sep 16, 2011 2:11:33 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.homepage_jsp._jspService(homepage_jsp.java:107)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Unknown Source)

Seems like your session is timing out. You have to either pressure the consumer to login again, or extend your session timeout.

You are able to alter the session timeout by editing your internet.xml and adding:

<session-config>
  <session-timeout>60</session-timeout>
</session-config>

Which provides you with a session timeout of an hour. -1 means there's no timeout.

java.lang.NullPointerException
    at org.apache.jsp.homepage_jsp._jspService(homepage_jsp.java:107)

The symptom this only happens following a very long time indeed signifies the session continues to be timed out. But altering the session timeout isn't the right solution. You've really a bug inside your JSP.

Because you are using traditional JSP scriptlets <% %> rather than normal Java classes for example servlets to manage the request/response and perform the business stuff within the JSP, it's harder to naildown the real cause from the NullPointerException. You have to open the produced homepage_jsp.java in server's work directory and mind to line 107 and lastly trackback this line to your homepage.jsp to ensure that you are able to fix the bug.

Possibly you have to perform a request.getSession() rather than request.getSession(false), or you have to see if a session attribute isn't null before being able to access it, etcetera.