File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Help me with session tracking example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help me with session tracking example" Watch "Help me with session tracking example" New topic

Help me with session tracking example

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have two html pages and I have the submit button in second page.
I have to save the data of the first page when the user navigates to the
second one. This can be done using Session tracking.
What I know is u can start of saying
HttpSession ses = request.getSession(true);
I am not sure how I will save the value in the fields of the first form.
Should I create String variables to save the data. If that is the case
I need not create a session object. What I will do is I will place a button called "continue" in my first html and check. If it is equal to
"continue" I will save it in String variables and if it is "submit" then I will try to do the reqd manipulation.

I am really sought of breaking my head about how to use session object to
save my data in first page. can anyone help me with a example code.
Just give me an example using two fields in first page and two fields
along with submit button in second page.
Please... I need ur help.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
A simple approach - assuming your servlet or JSP writes the second page, is to just re-write those first page form values into the second page form as type="hidden" variables, that way when you process the second page all variables will be there.
Your servlet can tell if it is getting a response from the first or second page with the same technique.
<input type="hidden" name="page" value="first" >
Sessions would also work but this is simpler and works no matter how the browser is set up.
subject: Help me with session tracking example
It's not a secret anymore!