| Author |
request.setAttribute not working while forwarding
|
Vijay Kashyap
Ranch Hand
Joined: Jul 30, 2001
Posts: 74
|
|
Hi, I am using the following code (in my servlet) for forwarding request to another page but whatever attributes being set before forwarding the request are getting lost. Could any body please point me out what I am doing wrong? Also whats the difference if I get Request dispatcher from HttpServletRequest rather than ServletContext ? Regards, Vijay
|
 |
Vijay Kashyap
Ranch Hand
Joined: Jul 30, 2001
Posts: 74
|
|
I got it. I am using getParameter to retrieve values in JSP which is causing all the problem. But still do point out whats the differenece in getting RequestDispatcher from SevletContext / HttpServletRequest ? Regards, Vijay
|
 |
Sandeep Jain
Ranch Hand
Joined: Oct 25, 2000
Posts: 124
|
|
Hello , I feel the data is getting lost because session is getting invalidated as the session id is not being passed by the first servlet to the next servlet. u before u farward the url attach the session id to it . u can do it by calling encodeURL method of HttpServletResponse class
|
Try and Try Till u succeed<br /> <br />Sandeep Jain
|
 |
Manjunath Subramanian
Ranch Hand
Joined: Jul 18, 2001
Posts: 236
|
|
Vijay: getRequestDispatcher(String URL) in ServletContext - takes an absolute URL as an argument where as the method in HttpServletRequest takes an argument which can be either an absolute URL or a relative URL
|
 |
Tony Alicea
Desperado
Sheriff
Joined: Jan 30, 2000
Posts: 3219
|
|
|
"Absolute" of course meaning from the web app root, not the server's...
|
Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
|
 |
vicky vickyqwe
Greenhorn
Joined: Feb 28, 2011
Posts: 2
|
|
Vijay Kashyap wrote:I got it. I am using getParameter to retrieve values in JSP which is causing all the problem. But still do point out whats the differenece in getting RequestDispatcher from SevletContext / HttpServletRequest ?
Regards,
Vijay
then what did you use to correct the problem???
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
vicky vickyqwe wrote:then what did you use to correct the problem???
One question mark is sufficient.
The solution is to use the correct means on the JSP to reference the request-scoped variable. That means the EL (expression language).
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: request.setAttribute not working while forwarding
|
|
|