aspose file tools*
The moose likes Servlets and the fly likes Pass value through hidden form field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Pass value through hidden form field" Watch "Pass value through hidden form field" New topic
Author

Pass value through hidden form field

asmita kesarkar
Greenhorn

Joined: Apr 13, 2006
Posts: 1
Hello,
In my application i displayed values using servlet by using queries.Now i want to pass that particular value to my next servlet which takes some additional information and values it recieve from previous servlet and fire query and generate result.Values have to be pass onlywhen i click link on the first servlet.
how can i recieve those passed values on next servlet?
thanks in advance,
asmita
Meghana Meduri
Greenhorn

Joined: Mar 29, 2006
Posts: 27
you can pass those values are url parameters to the second servlet url,
or you can have them as hidden fields and when you click on the hyperlink, submit the form, the action of the form would be your second servlet.
In later case, when you submit the form the values are automatically sent in request object to your second object.

If you are using JSP and usebean tag, then the values are set to the bean defined in the usebean tag. and from your servlet get the bean from the scope defined in the usebean and get values from the bean
Ganesh Chinni
Greenhorn

Joined: Dec 30, 2005
Posts: 24
Hi,

If you are displaying values in some input boxes in your current servlet then you can reterive the same in the next servlet using(provided the input boxes are inside the <form> tag),

Request.getParameter(String parameterName) method.

The second case is, if you are displaying it as labels in the current servlet then u can use hidden fileds in your current servlet and populate the hidden fields with the values. Then on Submit of the form you can retrive the same values in your next servlet using the same method mentioned above.


If you are not using the submit button, instead if you are using a hyper link to go to the next servlet then you can append the values at the end of the URL as follows(example),

http://localhost/WebApp/Servlet2?userName=xyz,

then you can retrive the id value in your next servlet as follows,
String name = request.getParameter(userName);


Hope this helps you.

Regards,
Ganesh
SCJB 1.4
SCWCD 1.4
SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass value through hidden form field