The registered accounts in my web application (Created using struts2) gets a separate site like http://localhost/accountname
And each account has its own login page. After registering, the users will get a separate site http://localhost/accountname
I want to scan the request URL (in struts2) first and then forward that request to the corresponding login page.
how can i do this? please help
You can get the request object in your action method by:
You can then find the request URL like this:
Then you can parse it and look for the pattern that you want and forward accordingly.
UPDATE:
You can use a package in the struts.xml configuration file. Lets say “userapps”.
In the ActionClass’s processURL method you can pull out the part of the URL that you are interested in and set a property lets say the user and his id. You then return success from your action.
You will have a second action called userpage say, that will take the user’s id and forward to the correct page.
Now, any url of the form localhost/myapp/userapps/anything.action will call the processURL method.