Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redirect="true" not working

 
Mike London
Ranch Hand
Posts: 1208
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

<forward
name="failure"
redirect="true"
path="/WEB-INF/jsp/testJSP.jsp"/>

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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1208
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
 
Nishita Jain
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
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/Login.do

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"
validate="true"
input="/jsp/login.jsp"
name="LoginBean"
redirect="true"
scope="request" >
<forward name="student" path="/jsp/studentInformation.jsp" />
<forward name="success" path="/jsp/testListing.jsp" />
<forward name="failure" path="/jsp/login.jsp" />
</action>


Thanks
-Nishita
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is NO attribute called redirect in action tag. It should be part of forward tag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic