views:

52

answers:

3

I need to do some pre-processing logic which reside in my Struts2 Action class, before showing index.jsp when user access my 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?

+2  A: 

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.

Faisal Feroz
i thought about this redirection. But is there any other approach with out redirection? :)
Veera
You can use a filter as well. If you are trying to handle the security concerns also then its is better to use filters.
Faisal Feroz
A: 

I guess i wanted to type filter servlet.

nwolisa
what is a tilter servlet?
Pablo Fernandez
I meant a servlet filter. I guess i mistyped it twice already.
nwolisa
A: 

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.

Pablo Fernandez