This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes redirect= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "redirect="true" not working" Watch "redirect="true" not working" New topic

redirect="true" not working

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
I'm getting the following error message when I have redirect="true" in struts-config.xml:

Status report

message /siteRoot/WEB-INF/jsp/testJSP.jsp

description The requested resource (/siteRoot/WEB-INF/jsp/testJSP.jsp) is not available.

If I remove the forward, I get the JSP's output on another page so clearly Struts is finding things.

The browser seems to be trying to access the correct file and the JSP file indeed seems to be in the right place.

Here's the part of the forward definition that seems to be problematic:


Any ideas why this wouldn't work?

I shouldn't need to include "siteRoot" in the forward's path above, should I?

Thanks in advance for any help or suggestions.

-- Mike
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
When you "redirect" it informs the browser to go fetch a different page. Outside users do not have access to files located under WEB-INF. Instead of redirecting to a jsp page, you can redirect to an Action that will show that page.

- Brent
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
i m little confuse here
by redirecting you want the atual pagename in url. am i write?
what i want is that when i login i want http://localhost:8080/TestMaster/testListing.jsp as my URL
but actually it gives me url like http://localhost:8080/TestMaster/

and i think redirect="true" can help me but how to do that?
Mike is asking the same for this reason?

<action path="/Login"type="com.indusa.testmaster.master.LoginAction"
scope="request" >
<forward name="student" path="/jsp/studentInformation.jsp" />
<forward name="success" path="/jsp/testListing.jsp" />
<forward name="failure" path="/jsp/login.jsp" />


Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
There is NO attribute called redirect in action tag. It should be part of forward tag.

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
I agree. Here's the link:
subject: redirect="true" not working
It's not a secret anymore!