I want to create a Struts2 Web Application with a functionality like:
if user A is logging in, then he can access the application like
http://product.com/a/login.jsp
if user B is logging in, then
http://product.com/b/login.jsp
and so on.
How can I achieve this?
Is it good to do this? or can I use Subdomain?
I'm pretty sure it doesn't work like that: in GMail (that you've taken as example) every user will always be redirected, after the log-in, to the same location:
If you enable the Google Multiple Sign-In, they will store separately the different log-in credentials server side, and will use different cookies client-side, with the same name but different paths:
Cookie for 1st account login:
Name : S
Content : gmail=someRandomHash
Server : mail.google.com
Path : /mail/u/0
Cookie for 2nd account login:
Name : S
Content : gmail=someRandomHash
Server : mail.google.com
Path : /mail/u/1
Then, when switching from one account to another, they will redirect you to a different URL:
1st account mailbox URL
2nd account mailbox URL
Once authenticated on both of them, you can manually switch between your different mailboxes by simply accessing the relative URL (try, if you have multiple accounts).
Conclusions: Google use different Rest URLs (with a named variable, in this case u
: user) to differentiate multiple accounts... for the same PC.
The added value is that you can switch between your multiple accounts without the need to log-out of the first and log-in to the second every time.
This has nothing to do with separating the URLs to handle different accounts ON DIFFERENT COMPUTERS.