wood burning stoves 2.0*
The moose likes Struts and the fly likes Dynamic path configuration/resolving Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic path configuration/resolving" Watch "Dynamic path configuration/resolving" New topic
Author

Dynamic path configuration/resolving

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I have a strange requirement herem, not sure if I can explain it properly, but let me try - I need to display different set of sites with dyamic paths such as -

http://xyz.com/people/1234/index.do?someparams=pqr
http://xyz.com/people/5678/index.do?someparams=pqr
http://xyz.com/people/1234/photos.do
http://xyz.com/people/5678/photos.do

Now - the NOS here (1234 or 5678) will be generated dynamially and the action will be requested - but they should resolve to the same action say - http://xyz.com/people/index.do?someparams=pqr and the action should also get the requested number in the path. Obviously it is not possible to add configurations for all those dynamic numbers, so there has to be only one action mapped here.

So what I want is this http://xyz.com/people/1234/index.do?someparams=pqr should resolve to http://xyz.com/people/index.do?someparams=pqr and it should also get "1234" as part of the info.

How can I achieve this?? I have not done this before but I think this sort of path manipulation should be possible.

Any pointers, help would be highly appreciated!

TIA,
- Manish
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possibility would be to create a Servlet Filter. By doing so, you can read the URI, examine it, and then forward to a different URI. So, for example, you could read a URI like
http://xyz.com/people/1234/index.do?someparams=pqr
and then forward to
http://xyz.com/people/index.do?Id=1234&someparams=pqr

For more information on Servlet Filters, see chapter 11 of the Sun J2EE 1.4 Tutorial.


Merrill
Consultant, Sima Solutions
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Hey, that should help!! Thanks a ton!!!

- Manish
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamic path configuration/resolving