Hello,
You can try the following:
<% if( htmlcSession==null or htmlcSession.guiEngine==null or
htmlcSession.guiEngine.pageManager= null
or htmlcSession.guiEngine.pageManager.statusPage== null
) { %>
<jsp:forward page="/Servlet?mustReInitialize='yes'" />
<% } %>
Now the servlet should check value of "mustReInitialize" parameter
from Request and should forward the request to
JSP page again after setting the values (using setAttributes()) in
the response.
Sandeep
-----Original Message-----
From: Peter Claesson (EUS) [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 21, 2001 7:36 PM
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
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets