• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 67637
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: 1512
  • 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
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic