jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes welcome-file and forwards... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "welcome-file and forwards..." Watch "welcome-file and forwards..." New topic
Author

welcome-file and forwards...

Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
I'm using Struts 2.0.9 with Tomcat (version 5.0.30 when launched via Cargo or version 6.0.10 when launched directly).

I have index.jsp listed in my welcome-file-list in the web.xml.

The contents of index.jsp are


When I hit the context root in the web-browser I get a 404 saying that /[context-root]/home.action is not available. When I go directly to /[context-root]/home.action, via the browser's location bar the page renders correctly.

So obvisiously
a) the request for the context root is getting routed to the index.jsp
b) the forward is occuring
c) something is happening differently for a forward to home.action versus direct navigation to home.action

Where should I be looknig to figure out what's happening?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Eric Nielsen:
c) something is happening differently for a forward to home.action versus direct navigation to home.action

You're right about that. The "something different" is that the forward uses the RequestDispatcher to dispatch the request after it has already been received. In this case, the Struts 2 interceptors don't have a chance to look at the request and decide what to do with it. I'd suggest using a meta refresh tag pointing to the action. That way, a "redirect" will occur, which means that an instruction will be sent back to the browser telling it to redirect to a different URI. When it's done this way, the Struts interceptors do have a chance to look at the request and act on it. Example:


Or you could do it this way:

[ September 23, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: welcome-file and forwards...
 
Similar Threads
Problem with direct access to login form
I Can not access my welcome file, frame.jsp?
does global forward work for this case ?
how to set html page as a welcome page in netbeans
multiple welcome files.