File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Route requests by address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Route requests by address" Watch "Route requests by address" New topic

Route requests by address

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi all
I would like to route part requests to specific Action,
For example:
For addresses finish with mng:
http://localhost:8080/myapp/mng -> Route the request to MngAction

For addresses finish with upl:
http://localhost:8080/myapp/upl -> Route the request to UploadAction

mng & upl doesn't really exist on my file system.

currently the configuration in the web.xml is :

So every ".do" request routed to the ActionServlet.
When a user wishes to go to the upload page,
he will enter the "upl" suffix,(without the ".do" part). he will just enter: "http://localhost:8080/myapp/upl"

What is the correct way to achieve this?
Any help will be appreciated deeply!
Thank you.
[ September 09, 2007: Message edited by: Sharon whipple ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possibility would be to create a servlet filter. In this filter, you could have logic that would read and analyze the incoming URL and change it to something else. For example, you could read the URL http://localhost:8080/myapp/upl and change it to http://localhost:8080/myapp/ so that Struts would know what to do with it.

Consultant, Sima Solutions
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
I did it using mapping insted of filter :

Then in the actionUpl I forwarded the request to the desired servlet

Thank you!
[ September 11, 2007: Message edited by: Sharon whipple ]
I agree. Here's the link:
subject: Route requests by address
It's not a secret anymore!