Help coderanch get a
new server
by contributing to the fundraiser
  • 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

struts action forward problem!

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my action class whenever i do a forward to a success jsp page the whole struts url gets forwarded as well.as a result the jsp page behaves as part of the struts application, how can i get round this. the jsp i want to get forwarded to is routed through a servlet which populates the jsp with some option values. how can i get the simple jsp page with no struts url attached.
i am using 'return mapping.findforward('success.jsp')'. Whts the difference between this and 'return new ActionForward('success.jsp').

thanks in advance.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want the URL to change when you forward to a JSP, you must specify redirect="true" when you define the forward. If you're creating the ActionForward dynamically, you must use the constructor that allows you to specify whether or not the forward is a redirect. Example:

One word of caution, though: When you redirect, you lose any information stored in the HTTPServletRequest, so to pass information to the JSP, you must either store it in the session or pass it with query string parameters.

i am using 'return mapping.findforward('success.jsp')'. Whts the difference between this and 'return new ActionForward('success.jsp').


The first refers to a named forward that you've defined in your struts-config.xml file. The second dynamically creates an ActionForward pointing to a specific URL.
 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, it works now.
what do you mean by:

When you redirect, you lose any information stored in the HTTPServletRequest, so to pass information to the JSP, you must either store it in the session or pass it with query string parameters.

.
In my ActionForward i have added the servlet path for the jsp , and its showing the correct jsp.Is that what you mean?
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic