开发者

Is it possible to invoke a Servlet before showing index.jsp

I need to do some pre-processing logic which reside in my Struts2 Action class, before showing index.jsp when user access m开发者_如何学JAVAy Java web application for the first time. I tried using the below snippet in web.xml but it failed:

web.xml:

<welcome-file-list>
    <welcome-file>loginPage.action</welcome-file>
</welcome-file-list>

To summarize, when user hits http://myjavawebap.com, first the struts2 action loginPage needs to be called and then the action should dispatch the default index.jsp file. Is there any way to achieve this?


Just redirect or forward to the loginPage in your index.jsp page and make index.jsp as the welcome-file.

Another solution could be to use a filter.


You might want to try a servlet filter for request preprocessing.

Also Struts 2 has a similar concept called Interceptors that might work for you in this case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜