• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Parameters

 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65128
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Michael Mendelson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suneel, hopefully this will help...
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic