This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Problem when typing the url http://localhost:8080/PrimeFaceDemo/login.xhtml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem when typing the url http://localhost:8080/PrimeFaceDemo/login.xhtml" Watch "Problem when typing the url http://localhost:8080/PrimeFaceDemo/login.xhtml" New topic
Author

Problem when typing the url http://localhost:8080/PrimeFaceDemo/login.xhtml

Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
Hi ,
Any one could help me to understand the bellow code in web.xml file.

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

because i'm facing one problem with my login .xhtml file i'm created one project and configured for prime face. Initially i'm done with the login.xhtml file bellow i'm copying the code bellow..

<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<ui:define name="content">
<h:panelGroup layout="block">
<form id="login-form" method="post">
<hutputText value="My Prime Face First Page" style="color:red" />
</form>
</h:panelGroup>
</ui:define>
</ui:composition>

if i'm typing the url : http://localhost:8080/PrimeFaceDemo/login.xhtml gives me blank page no out put.

i created one jsp page in the same login.xhtml place..and tried the url

http://localhost:8080/PrimeFaceDemo/test.jsp ..then this url is working fine ..
but im wondering why login.xhtml is not working..

Anyone could give me some help in this topic ...




Thanks in Advance...
Sijesh
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Not sure but can you try http://localhost:8080/PrimeFaceDemo/login.jsf

You're mapping *.jsf on your faces servlet.


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

1. You can make your code and XML samples a lot easier to read if you use the "Code" button on the message editor.

2. The technical term for a J2EE webapp that implements its own login code is "hacked" or "pwned".

3. Do not mistake URL paths for resource paths. a/b/c.xhtml is a resource path. It is the location of a resource "file" in a WAR file (or exploded WAR directory). The corresponding URL would be "http[s]://myserver:8080/mywebapp/a/b/c.jsf". A URL does not actually indicate the location of a resource, but simply serves are an identifying string that the webapp can use to access a resource or resources.

In a Facelets/JSF webapp set up with the commonly-used URL mapping options, ".jsf" URLs are broken down by the FacesServlet to get the URL fragment "a/b/c.jsf", which is then remapped to create the resource path "a/b/c.xhtml". This resource is then read and processed by the FacesServlet and the Facelets support code in order to generate the returned HTML.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
Hi Mark,

thanks for your response :-) .may i know one more thing .if i want to save the file like .xhtml (eg: login.xhtml).How do i need to map.


Cheers,
Sijesh
Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
Hi Tim,

In My case if i written the code like this ,eg: login.xhtml its not working.


<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:panelGroup >
<h:form id="login-form" >
<hutputText value="My Prime Face First Page" style="color:red" />
</h:form>
</h:panelGroup>
</ui:composition>



but if the written the code ed: login.xhtml like bellow its working..


<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:panelGroup >
<h:form id="login-form" >
<hutputText >My Prime Face First Page</hutputText>
</h:form>
</h:panelGroup>
</ui:composition>


it means that the imported components(bellow mentioned ) are not getting reflected.. Im i Right?

xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"


Tim i have one more query ,if it is possible to do technical -java online chating.If possible could you please guide me .

also is it possible to chat in skype .if possible my id is sijeshavs2


beveling the best from you ..

Thanks,
Sijesh
Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
Hi All,

Thanks For all.my issuse got resolved .In web.xml file i added ,

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

both then its works fine in mozilla.but in chrome still i'm facing problem.Any one help me to fix the problem in chrome..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

You are making the common mistake of confusing a resource path (/PrimeFaceDemo/login.xhtml) with a URL (http://localhost:8080/PrimeFaceDemo/login.jsf).

Web clients cannot access resource directory. Web clients submit URL requests. If the URL matches a URL pattern for a servlet (such as the FacesServlet), the webapp container will route that request to that servlet. In the case of JSF/Facelets, that would be the FacesServlet, which parses the URL and deconstructs it to create a corresponding View Resource path. The FacesServlet will then open that resource and compile it into an internal View component tree (note that this is different than JSPs, which are directly compiled to create servlets).
Sijesh Alayaril
Ranch Hand

Joined: Jan 13, 2012
Posts: 37
Hi Tim,

in my case http://localhost:8080/PrimeFaceDemo/login.jsf is not working in google chrome ,its working only in mozilla firefox .Some browser compatibility issue i think so.


Thanks & Regards,
 
 
subject: Problem when typing the url http://localhost:8080/PrimeFaceDemo/login.xhtml
 
Similar Threads
Primefaces setup causing problems JSF 2.0
xHtml and Facelets
Login Form with Spring Security + JSF2.0 + Facelets + RichFaces
Error JSF 2.1: java.io.FileNotFoundException:*/*.xhtml Not Found in ExternalContext
JSF, Facelets losing context after reload