webtier@glassfish.java.net

Suffix mapping causing .xhtml to be appended to resources served with h: tags

From: <forums_at_java.net>
Date: Fri, 6 Jan 2012 08:56:12 -0600 (CST)

Way back I switched our application to use suffix mapping, so I have this is
the web.xml:     <servlet-name>FacesServlet</servlet-name>  
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>  
<load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>  
<servlet-name>FacesServlet</servlet-name>  
<url-pattern>*.xhtml</url-pattern> </servlet-mapping>   Immediately after
the change I noticed that static resources such as javascript, css & image
files served using h:outputScript, h:outputStylesheet & h:graphicImage tags
all had .xhtml appended to them. So I'd have <h:outputScript
name="jquery.js"> and the page source rendered to the browser would be
<script type="text/javascript"
src="/context-root/javax.faces.resource/jquery.js.xhtml"/>. Despite this
apparent disconnect the resource is served successfully.   The problem is
that in the application I want to set real *.xhtml files to no-cache, and
cache real static resources. With this phantom .xhtml append problem
everything is getting treated as an xhtml file and set to no-cache.   I just
reproduced this in a netbeans shell web project so it's either something
setup incorrectly in my glassfish 3.1.1 server configuration, although this
seems unlikely, or it works like this for everyone.   I logged this jira in
july last year http://java.net/jira/browse/JAVASERVERFACES-2153 [1] but now
we're system testing and I've got to find a resolution, even if this is to
revert to prefix mapping.   Has anyone got any ideas why this might be
happening, what I can do to resolve the problem? One thing I should mention
is that I don't have a problem using standard html tags, so if I use <img
src="/context-root/ javax.faces.resource/myimage.png" everything works as it
should do, and the same for script and style tags.   Thanks.   I use
Mojarra 2.1.3 but this problem has been occurring with versions prior to
that.

[1] http://java.net/jira/browse/JAVASERVERFACES-2153

--
[Message sent by forum member 'oversteer']
View Post: http://forums.java.net/node/880528