| Author |
value pass from one servlet to another
|
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
|
how can we pass a value from one servlet to another without using session variable?
|
 |
Eshwin Sukhdeve
Ranch Hand
Joined: Mar 15, 2012
Posts: 78
|
|
|
you can use RequestDispatcher to forward to another servlet.if the data exist in request object
|
 |
rakhi sinha
Ranch Hand
Joined: Mar 26, 2012
Posts: 147
|
|
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
|
 |
Anurag Verma
Ranch Hand
Joined: Mar 30, 2012
Posts: 118
|
|
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
Joined: Mar 26, 2012
Posts: 147
|
|
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...
|
 |
mallikarjun dontamsetti
Ranch Hand
Joined: Mar 18, 2011
Posts: 233
|
|
|
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
Joined: Mar 26, 2012
Posts: 147
|
|
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
Joined: Mar 30, 2012
Posts: 118
|
|
|
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
Joined: Mar 26, 2012
Posts: 147
|
|
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
|
 |
 |
|
|
subject: value pass from one servlet to another
|
|
|