Java – How to set the welcome page to a struts action


I have a struts-based webapp, and I would like the default "welcome" page to be an action. The only solutions I have found to this seem to be variations on making the welcome page a JSP that contains a redirect to the action. For example, in web.xml:


and in index.jsp:


Surely there's a better way!

Best Solution

Personally, I'd keep the same setup you have now, but change the redirect for a forward. That avoids sending a header back to the client and having them make another request.

So, in particular, I'd replace the


in index.jsp with

<jsp:forward page="/MyAction.action" />

The other effect of this change is that the user won't see the URL in the address bar change from "http://server/myproject" to "http://server/myproject/index.jsp", as the forward happens internally on the server.