This is probably a basic session type question, but I'm a relative newbie. I
have the book, "JavaServer Pages," by Hans, but I'm still unclear where my
error is. Sorry, this is a little lengthy, but I'm trying to give all the
details. Here are the details:

Tomcat3.2.1
WinNT4
JDK1.3

1. I have a login jsp that goes to a servlet. This servlet handles login
security, then routes the user to the appropriate jsp page via the "forward"
method.

2. Now, say the user is at an options.jsp page and they select the 'reports'
option. This sends them to another servlet that routes the user to a
reports.jsp page based on the request.getParameter() value. Then, again I
use the "forward" method to send them to the reports.jsp.

3. The user picks a report and next, it goes to another servlet. In this
servlet, I make calls to a ReportsManager class. This class gets the data
from the database. Next, I have getters/setters on the ReportsBean. I use
the setter to set the data in this class. Inside this servlet, I again make
a "forward" call to send the user to a jsp page that will display the data
in a table.

4. Once Tomcat tries to display this final page, it throws a
NullPointerException. This is because, I don't have my ReportsBean set
throughout my session - I think. Inside my servlet (in step 3), I make a
call to my getter method on ReportsBean and that does give me all the
correct data(via System.out's).
Do I have to do getValue/putValue on the session object inside my servlets
to keep the session object persistent throughout my pages?????

My Login.jsp has this section for my jsp code:

<%@ page import="born.util.*" %>
<% ReportsBean reportsBean = new ReportsBean();
session.putValue("reports", reportsBean);  %>

My other jsp's have this section:

<%@ page import="born.util.*" %>
<% String userName = request.getParameter("userName");
ReportsBean reportsBean = (ReportsBean)session.getValue("reports");
HttpSession httpSession = request.getSession(true);
httpSession.putValue("currentPage", "Options.jsp");
%>


______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup

===========================================================================
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

Reply via email to