Results 1 to 2 of 2
  1. #1
    ShinTec's Avatar
    ShinTec is offline Member
    Join Date
    Jan 2010
    Posts
    51
    Rep Power
    0

    Question web app not working HTTP 404 status

    Hi Forum
    my web app is not working every time i try and run it it come up with the HTTP 404 status
    using Tomcat 6.029, eclispe hellios, JSF 2.0
    hear is my code
    //-------------------------------
    web.xml
    Java Code:
    <?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"
      xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5">
      <!-- The bare minimum needed for JSF 2.0 is a servlet 2.5
          declaration and the mapping for the FacesServlet.
          Setting PROJECT_STAGE to Development is highly recommended
          during initial development so that you get more helpful
          error messages.
          
          From JSF 2.0 tutorial at http://www.coreservlets.com/JSF-Tutorial/jsf2/
      -->
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
      <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    //-----------------------
    faces.config has nothing in it
    Java Code:
    <?xml version="1.0"?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
       version="2.0">
      <!--  Empty for now. Your entries will go here. But even
            if you have no entries in faces-config.xml, you are required
            to have a valid faces-config.xml file with legal 
            start and end tags.
            
            From JSF 2.0 tutorial at http://www.coreservlets.com/JSF-Tutorial/jsf2/ -->
            
       
    </faces-config>
    //--------------------------------------
    welcome page
    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http:/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
     <html xmlns="http://www.w3.org/1999/xhtml"
     	   xmlns:h="http://java.sun.com/jsf/html">
     	   <!-- This is the welcome page
    	  which displays a button that random select
    	  page1,2 or 3 and then display it.-->
    	  
     	   <h:head><title>Welcome Page</title></h:head>
     	   <h:body>
     	   <div align="center">
     	   <h2>Press button to return a random page</h2>
     	   <h:commandButton value="select random page" action="#{aBasicBean.doNavigation}"/>
     	   </div>
     	   </h:body>
     
     
    </html>
    //-------------------------------
    page1.xhtml
    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    	  xmlns:h="http://java.sun.com/jsf/html">
    	  <!-- This is the lst results page 
    	  which displays words related to the number one
    	  in english ,samoan and japanese-->
    	  <h:head>
    	  </h:head>
    	  <h:body>
    	  <div align="center">
    	  <table border="5">
    	  <tr><th class="title">Results page 1</th></tr>
    	  </table>
    	  <p/>
    	  <h1>One Tasi ichi</h1>
    	  
    	  </div>
    	  
    	  
    	  </h:body>
    
    </html>
    //--------------------------------------
    page2.xhtml
    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml"
    	  xmlns:h="http://java.sun.com//jsaf/html">
    	  <!-- This is the second results page 
    	  which displays words related to the number two 
    	  in english ,samoan and japanese-->
    	 <h:head></h:head>
    	 <h:body>
    	 <div align="center">
    	 <table border="5">
    	  <tr><th class="title">Results page 2</th></tr>	 
    	 </table>
    	 <p/>
    	 <h1>Two Lua Ni</h1>
    	 </div>
    	 </h:body>
    </html>
    //-------------------------------------
    page3.xhtml
    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    	  xmlns:h="http://java.sun.com//jsf/html">
    	   <!-- This is the three results page 
    	  which displays words related to the number three 
    	  in english ,samoan and japanese-->
    	  <h:head></h:head>
    	  <h:body>
    	  <div align="center">
    	  <table border="5">
    	  <tr><th class="title">Results page 3</th></tr>
    	  </table>
    	  <p/>
    	  <h1>Three Tolu San</h1>
    	  </div>
    	  </h:body>
    
    </html>
    //-----------------------------
    index.jsp
    Java Code:
    <% response.sendRedirect("welcome.jsf"); %>
    //------------------------------
    ABasicBean
    Java Code:
    package aNewPackage;
    
    /*a simple backing bean
    with a method that does my navigation*/
    
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    
    @ManagedBean(name="aBasicBean")
    public class ABasicBean 
    {
    	//private attributes
    	
    	//constructor
    	
    	
    	//class methods
    	public String doNavigation()
    	{
    		String [] results = {"page1","page2","page3"};
    		return(RandomUtils.randomElement(results));
    	}
    	
    	//get set methods
    	
    
    }//end of bean aBasicBean
    //--------------------------------------------------
    class RandomUtils
    Java Code:
    package aNewPackage;
    
    /*this class is a utility class
    it has one method. can add more
    if you desire*/
    public class RandomUtils 
    {
    	
    	/*This method returns randomly selects
    	a single string from an array of String 
    	*/
    	public static String randomElement(String [] arrayGiven)
    	{
    		//create local variables
    		String results;
    		int randomNum;
    		
    		//now calculating random number
    		randomNum=(int)Math.random() * (arrayGiven.length - 1);
    		
    		/*now using random num to randomly select a string value
    		so it can be assigned to the results variable then 
    		returing it*/
    		 results=arrayGiven[randomNum];
    	
    		return results;
    	}//end of method randomElement
    	//--------------------------------------------------
    
    }//end of class RandomUtils
    //------------------------------
    why is this error showing up :confused:
    any help would be much appreciated and thank you in advance

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    404 is a not found error. Make sure your war is in the correct location and that the URL you use to lookup its contents points to the correct location.

Similar Threads

  1. HTTP Status 500 -
    By gardiann in forum Java Servlet
    Replies: 2
    Last Post: 12-26-2010, 12:49 PM
  2. http status 500
    By swathi dharmaraj in forum Java Servlet
    Replies: 4
    Last Post: 12-14-2010, 04:46 PM
  3. HTTP Status 500(problem)
    By waqar100 in forum NetBeans
    Replies: 1
    Last Post: 06-30-2010, 11:54 AM
  4. Replies: 7
    Last Post: 11-11-2009, 08:29 PM
  5. Http Status 404 - LoginServlet.do
    By mbalas2 in forum Java Servlet
    Replies: 4
    Last Post: 03-05-2009, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •