• 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

value pass from one servlet to another

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can we pass a value from one servlet to another without using session variable?
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use RequestDispatcher to forward to another servlet.if the data exist in request object
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eshwin Sukhdeve wrote:you can use RequestDispatcher to forward to another servlet.if the data exist in request object


but i have to pass a value(to another servlet) which i got from another servlet using session object.......

i have to pass this value of n to another servlet so that i can use it in another servlet....
i am using Request dispatcher through following code but null value is retrieved that is following error is showed.
anull.pdf is not found as pdf or resource
 
Ranch Hand
Posts: 171
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set the data into request attributes & fetch it back into next servlet. ie on first servlet, write -

request.setAttribute("key", valueObject);

& in second servlet, write -

Object valueObject = request.getAttribute("key");
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anurag Verma wrote:set the data into request attributes & fetch it back into next servlet. ie on first servlet, write -

request.setAttribute("key", valueObject);

& in second servlet, write -

Object valueObject = request.getAttribute("key");


i have done it but null value is being passed...
 
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why are you setting it again in the session. it is already in session so get it where ever you require it.
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mallikarjun dontamsetti wrote:why are you setting it again in the session. it is already in session so get it where ever you require it.


we can use this session object in any servlet ...... but in another servlet it is taking null value
 
Anurag Verma
Ranch Hand
Posts: 171
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
attributes in a servlet remains only till the instance of request (in which we have put the attribute) is alive. once the response is sent, it wont be available (even on further requests by same client.). what exactly are you doing & what exactly do you want??
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anurag Verma wrote:attributes in a servlet remains only till the instance of request (in which we have put the attribute) is alive. once the response is sent, it wont be available (even on further requests by same client.). what exactly are you doing & what exactly do you want??



i was doing some mistake now it is running
 
reply
    Bookmark Topic Watch Topic
  • New Topic