• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

request dispatcher forward to struts 2 action

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any update on this yet?

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

 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)...
 
Krem Reid
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the update mate

 
Let's go to the waterfront with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic