This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts action forward problem!