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.

Leave a Comment