Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to redirect in Struts .do page?

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I would like to do a redirection in a .do page.

My code in the execute method:

return mapping.findForward("Mypage.jsp");

The page managed to redirect to Mypage.jsp but the URL in the browser is still the original .do page. Now, Mypage.jsp, I have some a href links, which cannot be clicked because it throws an exception. The a href links are valid.

Please help.

If you require more information, do ask me for more.

Thanks.
 
Alan Blass
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies. What I meant was:

return mapping.findForward(Mypage);

and Mypage is defined in my struts.xml as

<forward name="Mypage" path="/jsp-mobile/sys/Mypage.jsp"/>
 
Bartender
Posts: 9559
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can accomplish this by including the "redirect" attribute:
<forward name="Mypage" path="/jsp-mobile/sys/Mypage.jsp" redirect="true"/>
This is usually a Bad Idea as the user will have the JSP page in their history and can then load it without going through the corresponding action first, which is probably not what you want them to do.
 
Alan Blass
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!