The moose likes Servlets and the fly likes Passing hidden fields between 5 different pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing hidden fields between 5 different pages" Watch "Passing hidden fields between 5 different pages" New topic

Passing hidden fields between 5 different pages

Mahesh Eshwarappa

Joined: Jan 04, 2001
Posts: 28

I have 5 TABS in my web application which represents 5 Jsp's
Whenever a user clicks on a tab a new Jsp is o/p on to the screen. In each Jsp am calling a bean to get data from the database for presentation purpose.
The user can randomly click on any tab and enter some parameters in the text box and select an option from a drop down list.
Each Jsp has about 2 drop downlists and textareas where the user will enter some data.
Whenever the user goes back to different tab the page should remember what he is selected before.
For ex If he is selected option1 in a dropdownlist in page1 of Tab1 and goes to tab2 and comes back to tab1.
The page should remeber what selections he made.
I would like to get ideas on how to implement this from u all.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
This is what the session is for. Create one or more session beans to hold the information you want, and populate them in the appropriate JSPs. The values will stay there until the session ends, and may be retrieved when building any of the pages.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mahesh Eshwarappa

Joined: Jan 04, 2001
Posts: 28
Hi Frank,
Say if user's selected some option and entered some infmn at the browser end.
Iam submitting a form which contains information about the user's selections.
At present am having some 10 hidden fields and am submitting them whenever the user clicks the tab.So the hidden fields are passed in all successive pages thru the request object.
How does session object scale with my method of passing hidden fields.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
By going to the use of HttpSession you can cut out the hidden field text. Just keep that data in the session. Session objects simply hold various named objects in a Hashtable - your tradeoff is the memory required for the session versus the reduced amount of text that must be transmitted. You can explicitly drop these objects when the user signs off or you can let the servlet engine dispose of them when the session times out. Default timeout is 30 minutes in the JRun and Tomcat servlet engines.

author of:
Mahesh Eshwarappa

Joined: Jan 04, 2001
Posts: 28
Hi Bill,
Iam using Weblogic Server as Application as well as Webserver and our webapplication is going to be accessed by 1000's of users in future. If the session objects of large size are created at the server for each user , What implication does it have on memory.
If this is a better trade off..
Does using cookies have any advantages over URLRewriting in terms of performance.
It is sorta covered in the JavaRanch Style Guide.
subject: Passing hidden fields between 5 different pages
It's not a secret anymore!