jsf 2.0 single web-application with multiple domains
I have jsf 2.0 web application (with ejb) that will serve multiple domains. 开发者_Go百科I need to load data according to domain name that user came from. So I have to get domain, invoke ejb service and save data in user session. Also, when user go to domainA.com and then change to domainB.com I should create new session.
How this could be done? Servlet, filter, phase listener, post construct in managed bean? Or maybe create multiple web-apps, one for each domain?
If you are going to use fully qualified domains and not subdomains I would recommend going with the separate deployments for each domain, this solves your issue with the session creation and shouldn't be difficult. You can get the domain name inside you servlets or other components having access to the Request object, from info associated with the request itself:
// Get client's hostname
String hostname = req.getRemoteHost(); // hostname
This method
returns the host name of the client sending the request. If the name is unknown, returns an empty string. The fully qualified domain name (e.g. "xyzws.com") of the client that made the request. The IP address is returned if this cannot be determined.
精彩评论