Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107

    [ JAVA J2EE ] JSF... risorsa non disponibile

    Ciao a tutti; ho iniziato a guardare un po' JSF, allora ho fatto un primo esempio e tutto andava ok; ne ho fatto un altro un po' + complicato e ho iniziato ad avere dei problemi; infatti, cambiando solo il faces-config.xml, quando clicco sull'url http://localhost:8080/faces/quizIndex.jsp, tomcat mi dice che la risorsa quizIndex.jsp non è disponibile; qualcuno sa dirmi perchè?
    Di seguito ri porto il web.xml e il faces-config.xml. Ciao a tutti.

    ERRORE TOMCAT:

    The requested resource (/quizIndex.jsp) is not available
    WEB.XML
    Codice PHP:
    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
     <display-name>CoreJsf</display-name>
      <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>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>
      <session-config>
       <session-timeout>1500</session-timeout>
      </session-config>
      <taglib>
        <taglib-uri>jsfCore</taglib-uri>
        <taglib-location>/WEB-INF/tld/jsf_core.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>htmlBasic</taglib-uri>
        <taglib-location>/WEB-INF/tld/html_basic.tld</taglib-location>
      </taglib>
    </web-app>

    FACES-CONFIG.XML

    Codice PHP:
    <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "D:/project/CoreJsf/CoreJsf/WEB-INF/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
      <application>
       <locale-config>
        <default-locale>en</default-locale>
        <supported-locale>it</supported-locale>
       </locale-config>
      </application>

        <navigation-rule>
        <from-view-id>/quizIndex.jsp</from-view-id>
        <navigation-case>
          <from-outcome>next</from-outcome>
          <to-view-id>/quizIndex.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>success</from-outcome>
          <to-view-id>/quizSuccess.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>failure</from-outcome>
          <to-view-id>/quizFailure.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>done</from-outcome>
          <to-view-id>/quizDone.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>startOver</from-outcome>
          <to-view-id>/quizIndex.jsp</to-view-id>
        </navigation-case>
      </navigation-rule>
        <managed-bean>
       <managed-bean-name>quiz</managed-bean-name>
       <managed-bean-class>com.angelo.bean.capitolo3.QuizBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>  </managed-bean>
      </faces-config>
    Per sviluppare utilizzo JBuilderX e mi appoggio sul suo TomcatLE 4.1.27; ciò che non riesco a capire è che un esempio precedente funzicava, ora non funzica.... Grazie a tutti e ciao.
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

  2. #2
    Utente di HTML.it L'avatar di Angelo1974
    Registrato dal
    Feb 2003
    Messaggi
    1,107
    Ciao; ritorno; non so se può esservi utile, cmq posto di nuovo web.xml, faces-config.xml, QuizBean.java e i file .jsp che uso; se qualcuno sa rispondermi mi dica dov'è che sbaglio io non riesco a capire

    WEB.XML:
    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <display-name>CoreJsf</display-name>
      <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>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>
      <session-config>
        <session-timeout>1500</session-timeout>
      </session-config>
      <taglib>
        <taglib-uri>jsfCore</taglib-uri>
        <taglib-location>/WEB-INF/tld/jsf_core.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>htmlBasic</taglib-uri>
        <taglib-location>/WEB-INF/tld/html_basic.tld</taglib-location>
      </taglib>
    </web-app>
    FACES-CONFIG.XML
    codice:
    <?xml version="1.0" encoding="iso-8859-1"?>
     <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "D:/project/CoreJsf/CoreJsf/WEB-INF/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
    
      <application>
       <locale-config>
        <default-locale>en</default-locale>
        <supported-locale>it</supported-locale>
       </locale-config>
      </application>
    
      <navigation-rule>
    
        <navigation-case>
          <from-outcome>success</from-outcome>
          <to-view-id>/quizSuccess.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>failure</from-outcome>
          <to-view-id>/quizFailure.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>done</from-outcome>
          <to-view-id>/quizDone.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
          <from-outcome>startOver</from-outcome>
          <to-view-id>/quizIndex.jsp</to-view-id>
        </navigation-case>
    
      </navigation-rule>
    
      <managed-bean>
       <managed-bean-name>quiz</managed-bean-name>
       <managed-bean-class>com.angelo.bean.capitolo3.QuizBean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    
    </faces-config>
    QUIZBEAN.JAVA

    codice:
    package com.angelo.bean.capitolo3;
    
    import java.util.ArrayList;
    import com.angelo.bean.*;
    
    public class QuizBean {
    
      private int currentProblem;
      private int tries;
      private int score;
      private String response;
      private String correctAnswer;
    
      // here, we hardwire the problems. In a real application,
      // they would come from a database
      private Problem[] problems = {
           new Problem( "What trademarked slogan describes Java development? Write once, ...", "run anywhere"),
           new Problem( "What are the first 4 bytes of every class file (in hexadecimal)?", "CAFEBABE"),
           new Problem( "What does this statement print? System.out.println(1+\"2\");", "12"),
           new Problem( "Which Java keyword is used to define a subclass?", "extends"),
           new Problem( "What was the original name of the Java programming language?", "Oak"),
           new Problem( "Which java.util class describes a point in time?", "Date")
           };
      public QuizBean() {
    
        startOver();
      }
    
      public String startOverAction() {
    
        startOver();
        return "startOver";
      }
    
      private void startOver() {
    
        currentProblem = 0;
        score = 0;
        tries = 0;
        response = "";
      }
    
      private void nextProblem() {
    
        correctAnswer = problems[currentProblem].getAnswer();
        currentProblem++;
        tries = 0;
        response = "";
      }
    
      // PROPERTY: question
    
      public String getQuestion() {
    
        return problems[currentProblem].getQuestion();
      }
    
      // PROPERTY: answer
      public String getAnswer() {
        return correctAnswer;
      }
    
      // PROPERTY: score
    
      public int getScore() {
        return score;
      }
    
      // PROPERTY: response
      public String getResponse() {
        return response;
      }
    
      public void setResponse(String newValue) {
        response = newValue;
      }
    
      public String answerAction() {
        tries++;
        if (problems[currentProblem].isCorrect(response)) {
          score++;
          nextProblem();
          if (currentProblem == problems.length) return "done";
          else return "success";
        }
        else if (tries == 1) {
    
          return "again";
        }
        else {
    
          nextProblem();
    
          if (currentProblem == problems.length) return "done";
          else return "failure";
        }
      }
    }
    MYINDEX.JSP
    codice:
    <%response.sendRedirect("faces/quizIndex.jsp");%>
    QUIZINDEX.JSP
    codice:
    <html>
      <%@ taglib uri="htmlBasic" prefix="h" %>
      <%@ taglib uri="jsfCore" prefix="f" %>
    
      <f:view>
        <f:loadBundle basename="prop.messages1_it" var="msg"/>
        <head>
          <title>
            <h:outputText value="#{msg.title}">
            </h:outputText>
          </title>
        </head>
        <body>
          <h:form>
            
    
    
              <h:outputText value="#{quiz.question}">
              </h:outputText>
            </p>
            
    
    
              <h:inputText value="#{quiz.answer}">
              </h:inputText>
            </p>
            
    
    
              <h:commandButton value="#{msg.answerButton}" action="#{quiz.answerAction}">
              </h:commandButton>
            </p>
          </h:form>
        </body>
      </f:view>
    </html>
    Se vuoi trovare l'arcobaleno, devi sopportare la pioggia

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.