How can I set the welcome page to a struts action?
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
<% response.sendRedirect("/myproject/MyAction.action");%>
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.
As of the 2.4 version of the Servlet specification you are allowed to have a servlet in the welcome file list. Note that this may not be a URL (such as /myproject/MyAction.action). It must be a named servlet and you cannot pass a query string to the servlet. Your controller servlet would need to have a default action.
<servlet> <servlet-name>MyController</servlet-name> <servlet-class>com.example.MyControllerServlet</servlet-class></servlet><servlet-mapping> <servlet-name>MyController</servlet-name> <url-pattern>*.action</url-pattern></servlet-mapping><welcome-file-list> <welcome-file>MyController</welcome-file></welcome-file-list>