| Author |
Forwarding a variable with request scope
|
Chandra Bairi
Ranch Hand
Joined: Sep 12, 2003
Posts: 152
|
|
hello friends, I have a variable x with request scope. now i am in a situation where if i traverse to page A x should not be visible and if i travel to page B x should be visible. can anyone help me out how this is possible. thanks shekar
|
Thanks,
Shekar
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
Are you forwarding tp page A and then Page B?
|
Groovy
|
 |
Chandra Bairi
Ranch Hand
Joined: Sep 12, 2003
Posts: 152
|
|
|
It can be to any page but it will be dynamic. it will depend on a variable and some condition
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
I am still not clear. Remove the attribute from request scope and store it in session scope. Whenever required pull it from session ans store it in request.
|
 |
Chandra Bairi
Ranch Hand
Joined: Sep 12, 2003
Posts: 152
|
|
i am not clear as well as what you need to answer my question. firstly let me make you clear that the scope hierarchy i feel is page request session and application/context. now I have put a variable(let us say x) in request scope in page A and i am supposed to have it in request scope. From A i can go either to page B or page C. but it i go to page B then i can see that variable i.e. i can just say request.getparameter() but if i go to page C i should not be able to get the current scope variables. i hope this is clear.
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
now I have put a variable(let us say x) in request scope in page A and i am supposed to have it in request scope. From A i can go either to page B or page C. but it i go to page B then i can see that variable i.e. i can just say request.getparameter() but if i go to page C i should not be able to get the current scope variables.
I guess you are talking about request attribute and not request parameters. You can remove the request parameters from the request scope by calling request.removeAttribute() when yopu forward to page C.
|
 |
Chandra Bairi
Ranch Hand
Joined: Sep 12, 2003
Posts: 152
|
|
|
I asked one of my friend and he said if we have to see a variable from request scope then it has to be jsp:forward and if we want to isolate it then it has to be redirect. is that true?
|
 |
Sainudheen Mydeen
Ranch Hand
Joined: Aug 18, 2003
Posts: 218
|
|
Hi In A, set the attribute in request scope only when are forwarding to B. Probably you have a condition that decide to forward to B or C. Set the request attribute inside the condition. --------------- Sainudheen
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Chandra Bairi: I asked one of my friend and he said if we have to see a variable from request scope then it has to be jsp:forward and if we want to isolate it then it has to be redirect. is that true?
If you redirect all request attributes and parameters are lost.
|
 |
 |
|
|
subject: Forwarding a variable with request scope
|
|
|