Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping current session

Status
Not open for further replies.

rorymurray

Programmer
Oct 16, 2001
44
AU
I am using a servlet to process information from an online survey.
Basically the servlet receives parameters from different pages.
With each page it stores the parameter values as session attributes, then forwards to the next page, which in turn posts more parameter values, the servlet stores them as session attributes and so on. Example below:

---//data from page 2---
session.setAttribute("two_1", request.getParameter("two_1"));

---//forward to next page
RequestDispatcher rd = getServletContext().getRequestDispatcher(request.getParameter("next_page"));
rd.forward(request,response);

Now this works fine while you are trying to access the attributes while still in the current page, but if, say you have stored page 2's attributes and then you process page 3's, when you want to refer to the value of page 2's they return null.
I have checked the session id to make sure it is the same but it appears as though it is the same session.

Any ideas? (Let me know if you want the full servlet code).

Thanks

Rory

P.S. I know I could just insert these values into the database as the data from each page comes in, but it will slow down performance with the number of database accesses required.
 
I would like to see the full servlet code, or at least a fuller section that shows:

1) How you're pulling the value from the session in the next servlet

2) How you know for certain that request.getParameter("two_1") isn't returning null in the first servlet (and storing null therefore in the session).

Thanks
 
I can email you the full code (550 lines).

send me an email at r.j.murray@curtin.edu.au .

I know that it is storing the correct value in the attribute because I tried doing a system.out.println() of the attribute, and it came out witht the right value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top