GeeCON Prague 2014*
The moose likes Servlets and the fly likes use of hidden fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "use of hidden fields" Watch "use of hidden fields" New topic
Author

use of hidden fields

gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109
what is the benifit of HIDDEN FORM FIELDS during SESSION TRACKING.
like it is written that the client send some information hidden and used by the server,what exactly the use is..
thank you
gaurav
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
You can use it to send values hidden from the user (i.e. no input box displayed). I use this for one application to send operation names from the client to a server which the Servlet will read and execute, and read other parameters if necessary. I wouldn't want this displayed in an input box, so making it hidden is useful.
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
Also keep in mind that if you are using hidden fields for session tracking you should take care not to hold any sensitive data in hidden fields since we can view the values held by the hidden fields by actually viewing the source of the html page.
- John


Do not let what you cannot do interfere with what you can do !!<br /> <br />SCJP & SCWCD 1.4
Rigel Kentaurus
Greenhorn

Joined: Feb 09, 2005
Posts: 11
Hidden form fields are not for session tracking.

We have two mechanism for session tracking, they are cookies and URL rewriting, the latest for the people that doesn't have cookies enabled in their browsers, I could only understand sending a session id in a hidden field when you have your own session tracker and are not using the one that is already with your server container (HttpSession and all), but why re-invent the wheel?

Hidden fields are for passing information between pages, sometimes I use a <input type="hidden" name="action" value="XXX"> and I clearly don't want that information displayed to the user
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Have you ever seen the movie Finding Nemo? When using hidden form fields to store session (or conversational) state, it's kind of like your server is Dory (the fish with no long-term memory). Everytime you talk to the server again, you have to re-introduce yourself and remind it of what you've spoken with it about in the past, by passing it all of that information in the hidden form fields. This does take some of the memory burden off of the server. However, it can be tough to make sure you're actually writing all of the necessary hidden form fields (and their appropriate values) back to the client for use in the next request.


James Carman, President<br />Carman Consulting, Inc.
dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
It's probably worth mentioning that hidden form fields are almost worthless if they're not written out by the Servlet/JSP itself (I'm assuming you're using Servlets here.) Hardcoding a hidden right into an HTML page doesn't typically serve any useful purpose, unless that field is being manipulated some way by JavaScript.


Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
According to my experiences, that hidden fields are used to store values that is not displayed to users (such as using text field).
Especially for storing the id of record is being displayed and the mode of process (such as ADD or UPDATE).

Correct me if I am wrong..

thanks
daniel
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here is a quote from my Internet Architecture page. The page very briefly discusses the pros & cons of each. See if it gives you some useful ideas ...

"Web applications often have to hold some information about the user for the time the user is browsing the site, say a shopping cart with several items in it. Designers have many choices about where to put such data. Here are a few:

[ February 10, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of hidden fields