my dog learned polymorphism*
The moose likes JSF and the fly likes X.509 URL rewriting problem with JSF navigation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "X.509 URL rewriting problem with JSF navigation" Watch "X.509 URL rewriting problem with JSF navigation" New topic
Author

X.509 URL rewriting problem with JSF navigation

Jeroen Meijer
Greenhorn

Joined: Jan 25, 2011
Posts: 5

Hi,

I'm currently investigating a JSF navigation problem I'm facing:

I have a JSF application which normally (on LAN) runs fine. Now we've setup a production server with PKI certificate. The server rewrites the URL in the format https://xxxx.xxx.xxx/Appname/faces/.Danainfo=.aasvxDb0zlmKyvLy-9R65.SSL+index.xhtml.

This works only on the login page (which is set by default in web.xml). Every page navigation after that (for example I click in a menu) doesn't work anymore

I can write (or download) a url rewrite filter, however i'm not sure if stuff like session information will remain.

Does anyone have a suggestion or advise? Thank you

Ps Please excuse my English
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

I think you're confusing resource names with URLs. They look a lot alike, but their functionality is totally different.

A resource (path)name is the directory/filename path for a resource such as an xhtml file within a WAR.

A URL is an Uniform Resource Locator, and what it really is is a more-or-less random string obeying certain formatting rules (which, alas, look a lot like filename paths), that is parsed and used to dispatch work in a webapp server.

In the case of JSF, the URL generally either contains the sub-path "/faces/" or ends with ".jsf". The web.xml has a corresponding pattern-match rule that routes URLs that match to the FacesServlet.

Unlike old-style JSPs, JSF View Definitions (xhtml files) are not compiled into servlets. Instead, the FacesServlet compiles them into a 2-dimensional tree-shaped data structure and uses that structure (component tree) as a reference for processing the JSF lifecycle. JSF is a Model/View/Controller implementation, and the FacesServlet is the primary Controller.

Your problem is that when you specify a URL with ".xhtml" at the end of it, that doesn't match the FacesServlet URL pattern matcher, so the URL gets routed to the appserver's default URL processor, instead. The default processor is what is used to serve up images, CSS, javascript, and other static resources. All it does is parse the URL to remove the server and protocol information (and the query string), then uses the results as a WAR resource path. The resource defined at that location (if found) is then simply copied verbatim to the client.

Therefore, if you want proper JSF processing, the URL should not end with ".xhtml", it must end with ".jsf", so that the FacesServlet will see it.

So how does a ".jsf" locate a ".xhtml"? Simple. The FacesServlet parses the URL to get the resource path string, substitutes, ".xhtml" for ".jsf", then opens the xhtml resource and digests the View Definition in that resource.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeroen Meijer
Greenhorn

Joined: Jan 25, 2011
Posts: 5

That's not what I meant. The solution / explanation that you give is just mapping

<context-param>
<param-name>facelets.VIEW_MAPPINGS</param-name>
<param-value>*.xhtml</param-value>
</context-param>

That's not my problem, the url rewriting https://xxxx.xxx.xxx/Appname/faces/.Danainfo=.aasv...0zlmKyvLy-9R65.SSL+index.xhtml. IS
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Facelets View mappings is not related to the formation of the URL. It's the rule that says how a URL is to be remapped into a Facelets resource. In other words, "http://myserver.com:8080/xyz/abc.jsf" will be remapped to the resource path "/xyz/abc.xhtml".

If I changed the view mapping from "*.xhtml" to "*.glork", then the file defining the view would have to be named xyz/abc.glork, instead.

The ".xhtml" should NEVER be part of any URL unless you remap the standard conventions to be effectively inside-out. The URL should be "index.jsf", not "index.xhtml". If it isn't, like I said, the FacesServlet won't process it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: X.509 URL rewriting problem with JSF navigation