File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes prefix/suffix mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "prefix/suffix mapping" Watch "prefix/suffix mapping" New topic
Author

prefix/suffix mapping

keith moon
Greenhorn

Joined: Dec 11, 2008
Posts: 3
I have a problem with prefix and suffix mapping. When I use prefix-mapping
my facelets configuration does not work. I get the error:

javax.servlet.ServletException: Error Parsing /welcomeJSF.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.


When I use suffix-mapping
the servlet works but I have a filter problem.

My filter proofes which page is requested by calling the HttpServletRequest method getPathTranslated(). With prefix I get extra path information so I can check if the requested page is the login page:
but with suffix-mapping getPathTranslated always returns NULL.



Could someone please help me, either how to set up facelets with prefix-mapping or when I use suffix-mapping how can I determine within the doFilter method that the login page was requested?

thanks,
Pablo


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

You have 2 different problems.

First, it looks like the JSF Facelets page you are attempting to display is not well-formed XML, possibly because there's something wrong with the "<?xml ?>" Processing Instruction that must be the very first item in an XML datastream.

Secondly you have your problem in the filter itself, which I'm not sure about. I can, however, tell you that servlet filters don't behave any different for JSF requests than for non-JSF requests, and that the filter gets invoked before the FacesServlet gets the URL and picks it apart.

You're looking for a JSP page URL. I hope that's what you intended to look for.


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

Joined: Dec 11, 2008
Posts: 3
Hi Tim,

thanks for your reply. The login page is not well formed as it is a normal jsf page and not a facelets page. With suffix-mapping this is not a problem, the page gets displayed. But when I change to prefix I get the error message. The same happens when I change the welcome-file to forward.jsp. Isn't it possible to mix facelets/normal jsf pages with prefix?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

"Prefix mapping" and "suffix mapping" are kind of artificial definitions. If you'll notice, the actual element name is "URL Pattern". Meaning that the container will attempt to match all incoming URLs against that pattern, and those that match are routed to the designated target. Or in your case, targets, since you're using the same URL pattern to select for the filter and to route to the FacesServlet. Which is OK if you don't want to filter the non-JSF URLs like image requests and so forth.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prefix/suffix mapping