Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Navigate to Another URL from JSP using request dispatcher and response.sendRedirect in Struts 1.2.9

Posted on 2009-04-14
2
1,924 Views
Last Modified: 2013-11-24
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..
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.

Open in new window

0
Comment
Question by:pradumb29
2 Comments
 
LVL 4

Expert Comment

by:aman123_123
ID: 24145297
Are you not getting any exceptions? Check your log files.
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.
0
 

Accepted Solution

by:
pradumb29 earned 0 total points
ID: 24226829
I did a bit of googling and found out that this is a wide spread problem with struts 1.2.9 .
I have instead put the code in action class and fixed the problem..

Thanks for your suggestions..
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pairs challenge 5 87
HSSFWorkbook cannot be resolved error 10 105
jboss wildfly 10.1 10 228
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question