Title: Null Pointer handling in bean
I am a newbie in this domain but perhaps a fresh set of eyes will help..
 
I believe you can set up an error page and in this error page you can check if you have a null pointer exception and if so you could forward the user to the page of your choice.  Of course I could be wrong :-).
 
HTH
Scott.

 
 -----Original Message-----
From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Peter Claesson (EUS)
Sent: Friday, September 21, 2001 2:36 PM
To: [EMAIL PROTECTED]
Subject: 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