0

I tried solutions from topics with same issue but that didn't work for me. So here is my story. I created very simple web project:

project

Here the code:

package user.bean;

import javax.annotation.ManagedBean;

@ManagedBean
public class User {

    private String firstName;
    private String lastName;
    private String email;

    User() {

    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}

First JSF:

<!DOCTYPE html>

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:head>    
        <title>User Registration Form</title>        
        <style>
            .error {color:red}
        </style>        
    </h:head>

     <h:body>
        <h:form>        
            <h:messages styleClass="error"/>        
            First Name: <h:inputText value="#{user.firstName}" 
                                     label="First name"/>
            <br/><br/>          
            Last Name: <h:inputText value="#{user.lastName}" 
                                    label="Last name" 
                                    required="true"/>
            <br/><br/>          
            Email: <h:inputText value="#{user.email}" 
                                    label="Email" 
                                    required="true"/>
            <br/><br/>          
            <h:commandButton value="Submit" action="user_response"/>            
        </h:form>
    </h:body>
</html>

Second JSF:

<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

    <h:head>
        <title>User Confirmation</title>
    </h:head>

      <h:body>
        <h:form>            
            User is confirmed: #{user.firstName} #{user.lastName}           
            <br/><br/>          
            Email: #{user.email}            
        </h:form>
    </h:body>
</html>  

At

xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"

I have: NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: org.eclipse.jst.jsf.core.validation.internal.facelet.messages

I tried:

  1. Close/reopen project.

  2. Rightclick project > Validate.

  3. Project > Clean... and clean selected project.

  4. Restart Eclipse.

Its didnt worked.

When I run it I faced: HTTP Status 404 So I tried this:

  1. Click on Window > Show view > Server or right click on the server in "Servers" view, select "Properties".

  2. In the "General" panel, click on the "Switch Location" button.

  3. The "Location: [workspace metadata]" should replace by something else.

  4. Open the Overview screen for the server by double clicking it.

  5. In the Server locations tab , select "Use Tomcat location".

  6. Save the configurations and restart the Server.

Than I add JSF 2.2 (Mojarra 2.2.0) by properties -> Java Build Path. No changes. So I delete it from Build Path and add to WEB-INF->lib. Run on server and face: HTTP Status 500 - Servlet.init() for servlet Faces Servlet threw exception. I added url-pattern and listener to my web.xmp:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>JSF</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</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>/faces/*</url-pattern>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>  
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

and faced HTTP Status 404 - /JSF/user_form.xhtml

Well I'm complete newbe right now and will be very greatful for little help here. Thanks.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Tven
  • 9
  • 2
  • https://stackoverflow.com/questions/11986847/java-ee-6-javax-annotation-managedbean-vs-javax-inject-named-vs-javax-faces – Kukeltje Jul 24 '17 at 08:01
  • And **what** topics did you try? See [ask] – Kukeltje Jul 24 '17 at 08:02
  • Thats main topics which I try: https://stackoverflow.com/questions/7546219/nls-missing-message-cannot-find-facelet-taglib https://stackoverflow.com/questions/16340711/tomcat-http-status-404 https://stackoverflow.com/questions/14968318/http-status-500-servlet-init-for-servlet-dispatcher-threw-exception https://stackoverflow.com/questions/24701091/http-status-500-servlet-init-for-servlet-appservlet-threw-exception – Tven Jul 24 '17 at 11:18

0 Answers0