开发者

JSF Servlet Arch Help needed

i want a mechanism in my web app as described below:

user will enter mydomain.com/CompanyName , depending upon the CompanyNameit will show its logo and its customized page, and i will take that parsed parameter in session again upon each request i will compare the parsed CompanyName and one stored in session , and if they matched then application will show the requested page with user's data.else it will be redirected to login page. and the main thing is i want this thing in JSF arch.

i tried taking a servlet that will resolve all request and it will parse and then will dispatch the request to prefered servlet,but problem is it goes in loop as again it re开发者_如何学JAVAsolves to the same controller servlet,


You can do this via a phase listener. You can define a global one in faces-config.xml (or using annotations, if JSF 2.0 is used)

<lifecycle>
    <phase-listener>com.yourcompany.CompanyPhaseListener</phase-listener>
</lifecycle>

There you have access to the FacesContext, from which you can obtain the current request URI. Parse it and store the appropriate attributes in the request, which you can later read on your pages.

The phase listener is executed on the specified phase(s), and perhaps you should choose RENDER_RESPONSE

For affecting the way your URLs appear in the browser, check PrettyFaces.


i tried taking a servlet that will resolve all request and it will parse and then will dispatch the request to prefered servlet,but problem is it goes in loop as again it resolves to the same controller servlet,

Use a Filter instead. It by default doesn't listen on forwarded requests, so you won't get an infinite loop on forwarding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜