HTML forms support input tags with the attribute hidden
ensuring whatever values are set to this input, are not visible in the browser.
This property of the input tag can be effectively utilized to pass on session info through the server. The following describes a session management scenario where hidden form fields could be used efficiently.
Example of Managing Sessions with Hidden Form Field
Let us consider a very small application where a user will input his name and surname from an HTML form. This name and surname data will be carried along HTTPRequest to a servlet FirstServlet. It will generate a view where the user will be greeted with name and surname and will also ask for the name of his/her pet through another HTML form to be sent to another servlet SecondServ where all three data will be shown.
Now it is to be noted that when the request reaches the SecondServ, SecondServ has no clue about the name and surname of the user, as HTTP, due to its virtue of statelessness, does not remember the request data.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.