You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marten Lehmann <le...@cnm.de> on 2005/07/26 20:21:30 UTC

how to set index.faces as welcome-file

Hello,

I tried to put the following into web.xml:

<welcome-file-list>
	<welcome-file>index.faces</welcome-file>
</welcome-file-list>

But obviously, this doesn't work, because there is no file index.faces, 
but index.jsp. However, if the index.jsp isn't called through 
index.faces, the FacesContext isn't used. How can I achieve this as 
expected? I don't want to use the plain old workaround with an 
index.html containing a refresh.

Regards
Marten

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: how to set index.faces as welcome-file

Posted by Marten Lehmann <le...@cnm.de>.
Hello,

thanks for your class. I'm not usig it (and I guess its partially wrong, 
because you can't simply append the welcome-file the the path-info), but 
it inspired me to create a better way: Through a filter. I attached the 
filter-class, you would integrate it in the web.xml as follows:

     <filter>
         <filter-name>FakeIndexFilter</filter-name>
         <filter-class>web.filter.FakeIndexFilter</filter-class>
     </filter>
     <filter-mapping>
         <filter-name>FakeIndexFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>

I didn't put a GPL-notice in there, but I guess it's useful for everyone 
and maybe it can be included in the Tomcat distribution as well.

The way it works is pretty simple: If the servletpath doesn't end with 
"/", the request is just passed to the next filter. If it does end with 
"/", it will be checked if the file index.jsp exists, because every 
.faces-file will be mapped to the according .jsp-file. If the .jsp-file 
exists, a forward to servletpath+index.faces will be done. Otherwise, 
the request is passed to the next filter, where you would possibly get 
the directory listing in the end.

Regards
Marten

Re: how to set index.faces as welcome-file

Posted by Martin Bromley <ma...@sustainable-energy.co.uk>.
It took me a while to get welcome files working with the SpringMVC web framework.

I created the attached servlet to get things working properly.  It requires servlet spec 2.4, and it works by mapping the welcome file to a servlet, WelcomeFileServlet, rather than direct to a JSP.  The WelcomeFileServlet then forwards it on to the correct servlet, and makes sure that the requestURI returns the right value (e.g. /index.htm rather than just /) It should work fine with JSF, if you configure it properly.

Here's an example of how to configure it in web.xml

	<servlet>
		<servlet-name>WelcomeFileServlet</servlet-name>
		<servlet-class>com.mbromley.util.servlet.WelcomeFileServlet</servlet-class>
		<init-param>
			<param-name>forward-to-servlet-name</param-name>
			<param-value>DispatcherServlet</param-value>
		</init-param>
		<init-param>
			<param-name>welcome-file</param-name>
			<param-value>index.htm</param-value>
		</init-param>
	</servlet>

It works by mapping the index page (index.htm in my case, index.faces or whatever in yours) to the WelcomeFileServlet:
	
	<!-- Exact mappings are needed below for the welcome-file feature to work with WelcomeFileServlet. -->
	<servlet-mapping>
		<servlet-name>WelcomeFileServlet</servlet-name>
		<url-pattern>/index.htm</url-pattern>
	</servlet-mapping>

and then defining the welcome file as 

<!-- This relies on the 2.4 spec allowing mappings to a servlet as opposed to just a real file (index.htm doesn't exist as a real file in any of the directories this feature is required).  The WelcomeFileServlet docs have lots of info on the correct setup of that class. -->
	<welcome-file-list>
		<welcome-file>index.htm</welcome-file>
	</welcome-file-list>

Take a look at the docs with the attached file for more.

Hope it helps,

Martin with an 'i' ;-)




Marten Lehmann wrote:
> Hello,
> 
> I tried to put the following into web.xml:
> 
> <welcome-file-list>
>     <welcome-file>index.faces</welcome-file>
> </welcome-file-list>
> 
> But obviously, this doesn't work, because there is no file index.faces, 
> but index.jsp. However, if the index.jsp isn't called through 
> index.faces, the FacesContext isn't used. How can I achieve this as 
> expected? I don't want to use the plain old workaround with an 
> index.html containing a refresh.
> 
> Regards
> Marten
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 

Tomcat 5.5.9 MIME Problem

Posted by Son Dang <sq...@comcast.net>.
Hi,

I have two in which I wanted IE to recognize
as a binary file.  So I added the following
entries into my application web.xml file.

    <mime-mapping>
        <extension>cab</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>mlf</extension>
        <mime-type>application/octet-stream</mime-type>
    </mime-mapping>

Tomcat started up fine without any problem.  When
I tried to access file with these extend, I am getting
a file not found error (HTTP 503).

Furthermore, without the entries in my application
web.xml file, Tomcat delivers a garbaged text file.

Thanks for any assistance you can give.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: how to set index.faces as welcome-file

Posted by Christoph Kutzinski <ku...@gmx.de>.
Create a dummy index.faces file.
I did it this wy with Struts and index.do so I assume it should work 
with faces, too.

hth,
Christoph

Marten Lehmann wrote:
> Hello,
> 
> I tried to put the following into web.xml:
> 
> <welcome-file-list>
>     <welcome-file>index.faces</welcome-file>
> </welcome-file-list>
> 
> But obviously, this doesn't work, because there is no file index.faces, 
> but index.jsp. However, if the index.jsp isn't called through 
> index.faces, the FacesContext isn't used. How can I achieve this as 
> expected? I don't want to use the plain old workaround with an 
> index.html containing a refresh.
> 
> Regards
> Marten
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org