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
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
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),