| Author |
Passing Parameters
|
Suneel Setlur
Ranch Hand
Joined: Nov 26, 2000
Posts: 202
|
|
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 ]
|
Suneel
|
 |
Roy Ben Ami
Ranch Hand
Joined: Jan 13, 2002
Posts: 732
|
|
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.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56232
|
|
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
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Suneel Setlur
Ranch Hand
Joined: Nov 26, 2000
Posts: 202
|
|
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.
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
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
|
 |
Michael Mendelson
Ranch Hand
Joined: Dec 19, 2000
Posts: 73
|
|
Suneel, hopefully this will help...
|
 |
Suneel Setlur
Ranch Hand
Joined: Nov 26, 2000
Posts: 202
|
|
Thanks Bosun....But I guess you have a look at my code and tell me where I am going wrong...coz the Weblogic Server gives me a NullPointerException. And this is the error Thanks
|
 |
 |
|
|
subject: Passing Parameters
|
|
|