• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to redirect in Struts .do page?

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! It works.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic