wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Route requests by address" Watch "Route requests by address" New topic
Author

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.
Sharon
[ 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/upl.do so that Struts would know what to do with it.


Merrill
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: http://aspose.com/file-tools
 
subject: Route requests by address
 
Similar Threads
Filter Chain Order
Problem with simple HTML - Servlet login
How to run servlet on Tomcat
Welcome file
dispatcher.forward(req, res): not able to invoke the jsp page