wood burning stoves 2.0*
The moose likes Struts and the fly likes struts action forward problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts action forward problem!" Watch "struts action forward problem!" New topic
Author

struts action forward problem!

ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
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.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
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?
 
 
subject: struts action forward problem!
 
Similar Threads
servlet action is not available
Remove form fields from URL during forward
Custom Action Forward in Struts
How to encode the path attribute in action mapping
Issue with Struts 2 Dispatcher Result