Title: Null Pointer handling in bean

I have a dilemma. The application I'm working on depends on a poller mechanism being active on the
client browser. This works fine, even the timeout on the server for detecting if the poller stops.
The problem arises when the client hits the Browser Stop button. The server correctly detects this
condition and invalidates the session. However, since the page is still visible in the client browser,
the user can press a button which posts a form to the server. The action form, message.jsp,
initializes a bean and tries to access some data. But since the session is gone, Null Pointer
pop up.

To summarize my question, is there a way to catch the null pointer exception in the JSP page
and then redirect to another JSP page which correctly can re-initialize the session?

My action page looks like this.

<%@ page import="com.upfront.htmlc.*"%>
<%@ page import="com.upfront.htmlc.gui.*"%>
<jsp:useBean id="htmlcSession" scope="session" class="com.upfront.htmlc.HtmlcSession"/>
<%
    StatusPage thisPage = htmlcSession.guiEngine.pageManager.statusPage;     <--------- NullPointer exception
    if( htmlcSession.custMessagingEngine != null ) htmlcSession.custMessagingEngine.processMessagePost( request );
%>
<html>
<head>
    <script>
        <%=thisPage.getPageDomainScript()%>
    </script>
</head>
<body bgcolor="<%=thisPage.getBackgroundColor()%>" topmargin=0 bottommargin=0 leftmargin=2 rightmargin=0 onDragDrop="return false;">

<center><%=thisPage.statusMessage.toHTML()%></center>
</body>
</html>

I indicated where the NullPointer occurr.

/Peter

Reply via email to