0

I am a total beginner i am using eclipse kepler to create my web application: an eduction portal i did already set the glassfish4 server(its working) and the properties of the project i am using primefaces along with jsf 2.2 i created the first page and i wanted to to try to run it on the server but nothing is showed its a 404 error The requested resource is not available. and i already added the primefaces jar to the classpath this is the code of the page index.html

    <!DOCTYPE html>
    <html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    >
    <head>
    </head>
    <f:view contentType="text/html">
    <h:head />
    <h:body>
    <h:form>
    <p:spinner />
    </h:form>
    </h:body>
    </f:view>
    </html>

and this is the code in my web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee     http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    id="WebApp_ID" version="3.1"
    xmlns:p="http://primefaces.org/ui">
    <display-name>Portail</display-name>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    </web-app>

i followed some steps from this article to create it http://computingat40s.wordpress.com/creating-a-simple-jsf-web-application-from-the-ground/ and my lib directory still empty i didn't add anything to it i didn't even started creating the entities

MeknessiHamida
  • 185
  • 1
  • 8
  • 28
  • which url did you call? make sure your html gets processed by your faces servlet. localhost:8080/application/faces/site.html is different from localhost:8080/application/site.html. Also i am quite sure you do not need to add xmlns:p to your web-config.xml you will never render it.. also when your files are html, oyu didn#t follow the linked tutorial.. – Vogel612 Nov 05 '13 at 14:02
  • about the tutorial not quite the same because he is using richfaces but i almost did as the author was trying to do . and about the url i just did a right click on the page index.html and "run on server" .i added the xmlns:p to the web.xml cause i thought that's the missed ressource – MeknessiHamida Nov 05 '13 at 18:52
  • okay listen. html is not that friendly.. you want to use primefaces, this requires your pages to be put through a nice faces servlet.. please try to change your files from html to xhtml. this means instead of doctype html you create an xml (where you put the whole xmlns stuff) and then do your html file – Vogel612 Nov 05 '13 at 18:56
  • here is some tutorial which should do the trick (uses maven though) http://www.itcuties.com/j2ee/getting-started-with-primefaces-using-eclipse-ide-and-maven/ this also might be helpful if you want to avoid maven http://www.coreservlets.com/JSF-Tutorial/primefaces/ – Vogel612 Nov 05 '13 at 19:01
  • as i am undrestanding i should create a template first then create the html files on that base. Ok i m going to try it now and i hope it works – MeknessiHamida Nov 05 '13 at 19:05
  • it worked . thanks for the links but i am already working on too much things in this project and i can't add maven it because it will make it more difficult. i am new to the stack how can i rate your answer – MeknessiHamida Nov 05 '13 at 19:22
  • well up to now everything was comments: answers got their own rating and comment section. you can also click the little tick under the rating to accept an answer (the one you think was best) – Vogel612 Nov 05 '13 at 19:36

1 Answers1

0

From the comments:

html does not allow faces servlet parsing. Please change your files to xhtml: these files are made by opening standard xml (where you also put the xmlns declarations)

This snippet is directly taken from the web-application i currently work on.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:of="http://omnifaces.org/functions">
<h:head />

please remember changing your Faces Servlet filter in the web-config

Vogel612
  • 5,620
  • 5
  • 48
  • 73
  • ok i kind of get what you want to say and this is the header of the edited code that worked correctly on the server ' ' thething with kepler is that you have the option to nly create a new html file and from the list of the types i choose html5 and i thought it will work – MeknessiHamida Nov 05 '13 at 19:45
  • i can see its in the buttom of the list but in my desgin of the apperance of th web application i am using htlm5 features and i think by choosing the .xhtml from template i can't use it which is a problem for me – MeknessiHamida Nov 05 '13 at 20:31