• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing Parameters

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suneel, hopefully this will help...
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic