aspose file tools*
The moose likes Struts and the fly likes request dispatcher forward to struts 2 action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "request dispatcher forward to struts 2 action" Watch "request dispatcher forward to struts 2 action" New topic
Author

request dispatcher forward to struts 2 action

Jeffry Santoso
Greenhorn

Joined: Mar 12, 2008
Posts: 4
Hello, I have problem in struts 2. Here is my case:



To access the action, just type http://localhost/project/home.action in browser.

The problem is, I have servlet and the servlet will be forward to that action (home.action). Here is my code:



I only just want to wrap the home action with one servlet (for SEO), but seems like it doesn't work. The browser said:


I'm sure I have done that in struts 1, which is redirect to "home.do", and it's work (I have tried before). But when I tried in struts 2, it said 404 not found.
My case is like the other case (I have googling, and found similar issue http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2007-06/msg01416.html)

I'm really appreciate anyone who want to help me. Sorry for my poor English. Thanks.
francis lin
Greenhorn

Joined: Oct 14, 2008
Posts: 5
Because Struts 2 uses a filter mechanism to do the dispatching job, instead of a servlet in Struts 1, and the "inner" forwarding action can not touch off a http request filter. I don't know any solution so far. Sorry for my worse English.
Jeffry Santoso
Greenhorn

Joined: Mar 12, 2008
Posts: 4
Hi francis, thanks for your reply. Yes, I have googling that. struts 1 is a servlet, so we can easily do request dispatcher forward to struts 1 action. And struts 2 is pojo class, that serve in FilterDispatcher as a servlet filter.
http://www.geekinterview.com/question_details/45416

I have debug struts 2 source code, and learn it (yeah, struts is open source ). I think we can use Struts 2 Dispatcher to forward. I'm pretty sure if the Dispatcher can done in Struts 2 Action, but not in Servlet...
Krem Reid
Greenhorn

Joined: Sep 07, 2009
Posts: 28
Any update on this yet?

I'm trying to forward from a filter to a struts2 action


Backlink Service - High PageRank Backlinks to have you flying up through the SERP
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Krem in the future try to create a new topic for your problem using button. Although I've not tried it, try to map your struts 2 filter to request dispatching too using the <dispatcher> tag of the <filter-mapping> tag (more info here)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Krem Reid
Greenhorn

Joined: Sep 07, 2009
Posts: 28
Hey

I know how to make a new topic but no point if these guys already worked out a solution.
Which I guess they have... or given up

Merry Christmas
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
I had the same problem, when I was porting a Struts1 Application to Struts2.

Ankit's solution seems to be work. Thanks Ankit.

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
Krem Reid
Greenhorn

Joined: Sep 07, 2009
Posts: 28
Thanks for the update mate

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request dispatcher forward to struts 2 action