Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Route requests by address

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic