pradumb29
asked on
Navigate to Another URL from JSP using request dispatcher and response.sendRedirect in Struts 1.2.9
Hi All,
I have a web application which is based on struts version 1.2.9 and tiles.
my screens are in 3 tiles, header, footer and body.i am trying to navigate to another URL from the header if a certain condition is fulfilled and am trying to use response.sendRedirect. but it does not work the only thing that happens is that header goes blank ...but rest of the footer and body remains there..
I tried to use request dispacher to navigate but with no luck..
I am pasting the code below..
Please let me know if some one knows how to get it working..
I have a web application which is based on struts version 1.2.9 and tiles.
my screens are in 3 tiles, header, footer and body.i am trying to navigate to another URL from the header if a certain condition is fulfilled and am trying to use response.sendRedirect. but it does not work the only thing that happens is that header goes blank ...but rest of the footer and body remains there..
I tried to use request dispacher to navigate but with no luck..
I am pasting the code below..
Please let me know if some one knows how to get it working..
if (cond==true)
String targetURL ="https://XXXXX"l+"/errorPage.do";
response.sendRedirect(targetURL.trim());
return;
This does not work and intresting the URL remained the same with header gone..
--------------------------------------------------------------------------------------------
then i tried request dispatcher..
RequestDispatcher dispatcher = request.getRequestDispatcher(targetURL.trim());
dispatcher.forward(request, response);
after this code i see nothing on the screen with URL remaining the same as it was before..
I am pretty sure that my URL is correct because i can see the intended screen if i type the URL
in browser i see it correctly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In case of redirect a new request is sent from the browser and hence all request parameters are lost. May be in your Header, you are performing some operation on the request parameter and getting NullPointerException. If that is the case, you need to append the request parameters in your url only.
As for forward, you can not forward after response has been committed. You need to understand how redirect and forward works.
Please post the code in the header file.