This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When I pass Parameters from one servlet to another using something like response.sendRedirect("http://webserver:7001/......?var=value") I get only the var in the second servlet and not the value. Where am I going wrong? Can you please give me a sample code.. [ June 15, 2002: Message edited by: Suneel Setlur ]
if you use sendRedirect then the parameters are not passed in the request, since it makes a new request on the client's browser. try using, the forward() method with the requestDispatcher to forward the request to the second servlet instead of sendRedirect.
Suneel, what exactly do you mean when you say that you "get the var but not the value"? What actions are you taking to get the value of "var" and what is being returned? I'm not yet convinced that this is a forward vs. redirect problem. bear
Hi Thanks for the replies. Ben can you give me an example code where I can pass a key & value pair like i=10 to the next servlet? Bear I hae no difficulties with redirecting. I was wanting to pass a couple of parameters to the next servlet where I indicated that the variable(var)and its value needed to go the next servlet.
Suneel, you can just add it as an attribute to the request and then forward it to your servlet. requestReference.setAttribute("Name", value) requestDispatcherReference.forward(requestReference, responseReference)
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley