webtier@glassfish.java.net

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

From: Lincoln Baxter, III <lincolnbaxter_at_gmail.com>
Date: Fri, 22 Jun 2012 10:00:49 -0400

In this case your easiest solution would be to revert to prefix mapping.
this is not a bug, and is necessary for these resources to be handled by
the faces servlet.

however, you could also attemp to apply url-rewriting to modify both the
outbound rendered resource url, and also capture and forward inbound
requests to the correct location.

http://ocpsoft.org/rewrite/ would let you do this, for example.

something like:

.addRule(Join.path("/resources/{resource}").to("/resources/{resource}.xhtml"))

would get you started, but you would probably need to specify the pattern
that "resource" matches.

---
Lincoln Baxter's Droid
http://ocpsoft.org
"Simpler is better."
On Jan 6, 2012 9:57 AM, <forums_at_java.net> wrote:
> 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<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<http://java.net/jira/browse/JAVASERVERFACES-2153>
>
> --
>
> [Message sent by forum member 'oversteer']
>
> View Post: http://forums.java.net/node/**880528<http://forums.java.net/node/880528>
>
>
>