Right now based on the site name in the URL parameter, we decide the appropriate actions to take(method calls etc) in the Java (Standard Jsp/Servlet web applications). For example, the request would be something like www.oursite.com?site=Ohio
Wondering what would be the alternative of doing this without having to provide URL parameter.
Right now based on the site name in the URL parameter, we decide the
Share
Why not just code it into the path?
http://www.oursite.com/Ohio
If you’re just using straight servlet api, you can just do something of this nature:
That being said, most web frameworks have some support for helping with this.
For example, in spring mvc:
Of course you could do this at the controller level too if all your methods need that sort of mapping:
I believe this is cleaner than a query param, though it still shows up in your URL. There’s other, more complex methods like using apache’s reverse proxying and virtual host capabilities to switch based on site names. You could do something at login, and store the site in session. It all depends on your requirements.