IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

servlets -> jsp


Sujet :

Servlets/JSP Java

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut servlets -> jsp
    bonjour j'ai un petit souci lors de l'apel a mes page jsp pour le code suivant

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package controller;
     
    import entity.Membre;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;	
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import session.MembreFacade;
     
     
    /**
     *
     * @author Coshom
     */
    @WebServlet(name = "controllerMembre", urlPatterns = {"/controllerMembre",
                                                          "/controller",
                                                          "/WEB-INF/"})
     
    public class controllerMembre extends HttpServlet {
        @EJB
        private MembreFacade membreFacade;
        private String userPath;
     
     
        /**
         * Processes requests for both HTTP
         * <code>GET</code> and
         * <code>POST</code> methods.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
     
     
           protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
     
     
            userPath = request.getPathInfo() ;
     
     
             List ListMembre = membreFacade.findAll();
            request.setAttribute("ListMembre", ListMembre);
     
     
     
            userPath = "index";  
          // use RequestDispatcher to forward request internally
            String url = "/WEB-INF/view/" + userPath + ".jsp";
           //System.out.println(url);
            try {
                request.getRequestDispatcher(url).forward(request, response);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
     
     
     
        }
     
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /**
         * Handles the HTTP
         * <code>GET</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Handles the HTTP
         * <code>POST</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Returns a short description of the servlet.
         *
         * @return a String containing servlet description
         */
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
    }
    j'ai le message d'erreure suivant :

    type Exception report

    message

    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

    exception

    java.lang.NoClassDefFoundError: session/MembreFacade
    note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.


    arboressance suivante :




    jsp suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <%-- 
        Document   : test
        Created on : 11 mai 2013, 18:08:19
        Author     : Coshom
    --%>
     
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>Hello World JSP mimi </h1>
     
        <c:forEach var="Membre" items="${ListMembre}">
                 ${ListMembre.nom}
        </c:forEach>
     
     
        </body>
    </html>
    merci d'avance

  2. #2
    Membre confirmé Avatar de ruscov
    Homme Profil pro
    Architecte de système d'information
    Inscrit en
    Mars 2007
    Messages
    347
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte de système d'information

    Informations forums :
    Inscription : Mars 2007
    Messages : 347
    Points : 500
    Points
    500
    Par défaut
    Je ne sais pas comment tu build ton war mais je pense que session/MembreFacade n'est pas dans ton war. Ouvre le et vérifies.
    S'il n'y est pas, fais un rebuild de ton projet.
    Mes logiciels n’ont jamais de bug. Ils développent juste certaines fonctions aléatoires.

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    en cliquant sur le projet général et clear and build il me met une page blanche maitant pourquoi il refuse de m'afficher la .jsp ?

    web.xml si ca peu aider :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 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-app_3_0.xsd">
        <servlet>
            <servlet-name>controllerMembre</servlet-name>
            <servlet-class>controller.controllerMembre</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>controllerMembre</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
    </web-app>

  4. #4
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    bonjour,

    pour le premier point c'est parce que tu n'as pas instancié membreFacade.

    Tu le definis comme variable d'état : MembreFacade membreFacade;

    et tu utilises ensuite : List ListMembre = membreFacade.findAll();

    il manque un membreFacade = new MembreFacade();

    d'ou l'erreur.

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    j'ai donc le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package controller;
     
    import entity.Membre;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;	
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import session.MembreFacade;
     
     
    /**
     *
     * @author Coshom
     */
    @WebServlet(name = "controllerMembre", loadOnStartup = 1,urlPatterns = {"/controllerMembre",
                                                          "/controller",
                                                          "/WEB-INF/"})
     
    public class controllerMembre extends HttpServlet {
        @EJB
        private MembreFacade membreFacade;
        private String userPath;
     
     
        /**
         * Processes requests for both HTTP
         * <code>GET</code> and
         * <code>POST</code> methods.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
     
     
           protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
     
            userPath = request.getPathInfo() ;  
            membreFacade = new MembreFacade();
            List ListMembre = membreFacade.findAll();
            request.setAttribute("ListMembre",ListMembre);
            userPath = "index";
          // use RequestDispatcher to forward request internally
          String url = "/WEB-INF/view/" + userPath + ".jsp";;
           System.out.println("coucouccocc");
            try {    
               request.getRequestDispatcher(url).forward(request,response);                   
            } catch (Exception ex) {
                ex.printStackTrace();
            }
     
     
     
        }
     
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /**
         * Handles the HTTP
         * <code>GET</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Handles the HTTP
         * <code>POST</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Returns a short description of the servlet.
         *
         * @return a String containing servlet description
         */
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
    }
    il me met le message d"erreur suivant :


    type Exception report

    message

    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

    exception

    java.lang.NullPointerException
    note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.


    mais en mettant le , loadOnStartup = 1 il se charge pas d'instancier tout?

  6. #6
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    on progresse,

    je pense maintenant que cette nouvelle erreur provient de

    [CODE]
    List ListMembre = membreFacade.findAll();
    /CODE]

    il semble que la méthode findAll() provoque cette erreur.

    tu peux donner le code de MembreFacade???

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    membre facade :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package session;
     
    import entity.Membre;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    /**
     *
     * @author Coshom
     */
    @Stateless
    public class MembreFacade extends AbstractFacade<Membre> {
        @PersistenceContext(unitName = "Coshom-ejbPU")
        private EntityManager em;
     
        @Override
        protected EntityManager getEntityManager() {
            return em;
        }
     
        public MembreFacade() {
            super(Membre.class);
        }
     
    }
    et absract

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package session;
     
    import java.util.List;
    import javax.persistence.EntityManager;
     
    /**
     *
     * @author Coshom
     */
    public abstract class AbstractFacade<T> {
        private Class<T> entityClass;
     
        public AbstractFacade(Class<T> entityClass) {
            this.entityClass = entityClass;
        }
     
        protected abstract EntityManager getEntityManager();
     
        public void create(T entity) {
            getEntityManager().persist(entity);
        }
     
        public void edit(T entity) {
            getEntityManager().merge(entity);
        }
     
        public void remove(T entity) {
            getEntityManager().remove(getEntityManager().merge(entity));
        }
     
        public T find(Object id) {
            return getEntityManager().find(entityClass, id);
        }
     
        public List<T> findAll() {
            javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
            cq.select(cq.from(entityClass));
            return getEntityManager().createQuery(cq).getResultList();
        }
     
        public List<T> findRange(int[] range) {
            javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
            cq.select(cq.from(entityClass));
            javax.persistence.Query q = getEntityManager().createQuery(cq);
            q.setMaxResults(range[1] - range[0]);
            q.setFirstResult(range[0]);
            return q.getResultList();
        }
     
        public int count() {
            javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
            javax.persistence.criteria.Root<T> rt = cq.from(entityClass);
            cq.select(getEntityManager().getCriteriaBuilder().count(rt));
            javax.persistence.Query q = getEntityManager().createQuery(cq);
            return ((Long) q.getSingleResult()).intValue();
        }
     
    }
    mais je pense pas que ca vienne de la car quand je fait un foreach directement dans ma servets il me les affiche bien les données

  8. #8
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    bonjour,

    tu as raison ça ne vient pas de là.

    tu peux enlever MembreFacade membreFacade=new MembreFacade();

    par contre, il y a une erreur dans ta jsp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <c:forEach var="Membre" items="${ListMembre}">
                 ${ListMembre.nom}
    </c:forEach>
    tu lui demandes d'afficher List<T>.nom????

    les éléments de ta liste sont les Membre et ta liste est ListMembre.
    Donc si tu veux afficher les attributs nom des éléments de la liste :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <c:forEach var="Membre" items="${ListMembre}">
                 ${Membre.nom}
    </c:forEach>

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    j'ai donc :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    <%-- 
        Document   : test
        Created on : 11 mai 2013, 18:08:19
        Author     : Coshom
    --%>
     
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>Hello World JSP mimi </h1>
     
     <c:forEach var="Membre" items="${ListMembre}">
                 ${Membre.nom}
    </c:forEach>
     
     
        </body>
    </html>

    et donc :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package controller;
     
    import entity.Membre;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;	
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import session.MembreFacade;
     
     
    /**
     *
     * @author Coshom
     */
    @WebServlet(name = "controllerMembre", loadOnStartup = 1,urlPatterns = {"/controllerMembre",
                                                          "/controller",
                                                          "/WEB-INF/"})
     
    public class controllerMembre extends HttpServlet {
        @EJB
        private MembreFacade membreFacade;
        private String userPath;
     
     
        /**
         * Processes requests for both HTTP
         * <code>GET</code> and
         * <code>POST</code> methods.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
     
     
           protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
     
            userPath = request.getPathInfo() ;  
     
            List ListMembre = membreFacade.findAll();
            request.setAttribute("ListMembre",ListMembre);
            userPath = "index";
     
          String url = "/WEB-INF/view/" + userPath + ".jsp";;
         //  System.out.println("coucouccocc");
            try {    
               request.getRequestDispatcher(url).forward(request,response);  
     
            } catch (Exception ex) {
                ex.printStackTrace();
            }
     
     
     
        }
     
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /**
         * Handles the HTTP
         * <code>GET</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Handles the HTTP
         * <code>POST</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Returns a short description of the servlet.
         *
         * @return a String containing servlet description
         */
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
    }
    et toujours une page blanche :s

  10. #10
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    essaie juste d'afficher la jsp pour voir ??

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
     
          String url = "/WEB-INF/view/index.jsp";
     
          request.getRequestDispatcher(url).forward(request,response);  
        }

  11. #11
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    type Exception report

    message

    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

    serais pas a cause du web.xml :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 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-app_3_0.xsd">
        <servlet>
            <servlet-name>controllerMembre</servlet-name>
            <servlet-class>controller.controllerMembre</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>controllerMembre</servlet-name>      
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <jsp-config>
            <jsp-property-group>
                <display-name>membre</display-name>
                <url-pattern>/WEB-INF/view</url-pattern>
            </jsp-property-group>
        </jsp-config>
    </web-app>

  12. #12
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    Bonjour,

    j'ai une aure idée :

    nomme ta jsp autrement et reteste avec le dernier processRequest épuré.

    Peux être que comme il appelle index.jsp par default ça crée une boucle?????

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    alors j'ai fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package controller;
     
    import entity.Membre;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;	
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import session.MembreFacade;
     
     
    /**
     *
     * @author Coshom
     */
    @WebServlet(name = "controllerMembre", loadOnStartup = 1,urlPatterns = {"/controllerMembre",
                                                          "/controller",
                                                          "/WEB-INF/"})
     
    public class controllerMembre extends HttpServlet {
        @EJB
        private MembreFacade membreFacade;
        private String userPath;
     
     
        /**
         * Processes requests for both HTTP
         * <code>GET</code> and
         * <code>POST</code> methods.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
     
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
     
          String url = "/WEB-INF/view/membrejsp.jsp";
     
          request.getRequestDispatcher(url).forward(request,response);  
        }
     
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /**
         * Handles the HTTP
         * <code>GET</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Handles the HTTP
         * <code>POST</code> method.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            processRequest(request, response);
        }
     
        /**
         * Returns a short description of the servlet.
         *
         * @return a String containing servlet description
         */
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
    }
    ensuite :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <%-- 
        Document   : test
        Created on : 11 mai 2013, 18:08:19
        Author     : Coshom
    --%>
     
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1>Hello World JSP mimi </h1>
     
     <c:forEach var="Membre" items="${ListMembre}">
                 ${Membre.nom}
    </c:forEach>
     
     
        </body>
    </html>
    j'ai toujour :

    type Exception report

    message

    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
    note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

  14. #14
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    En regardant sur google, il semble que cette erreur aie rapport avec la compatibilité avec JSF. Mais là je ne connais pas trop......

  15. #15
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    je peux m'y prendre comment ? tes sur que c'est pas mon web.xml qui poserais probleme?

  16. #16
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    312
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 312
    Points : 533
    Points
    533
    Par défaut
    Essayons un dernier truc,

    n'utilise pas processRequest() mais directement doget(). efface doPost() et processRequest()

    tu ne gardes que doGet() dans ta servlet:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            this.getServletContext().getRequestDispatcher("/WEB_INF/membrejsp.jsp").forward(request,response);
        }

  17. #17
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2009
    Messages
    226
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2009
    Messages : 226
    Points : 72
    Points
    72
    Par défaut
    type Exception report

    message

    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
    note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

Discussions similaires

  1. [Info][JSP] achat livre sur les servlets et jsp
    Par mealtone dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 24/10/2005, 11h14
  2. [jsp][servlet] communication jsp servlet
    Par villeneuvejsp dans le forum Servlets/JSP
    Réponses: 15
    Dernier message: 03/10/2005, 15h36
  3. [ SERVLET ] [JSP ] Redirection servlet vers JSP
    Par Enfa dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 23/02/2005, 14h55
  4. [servlet][tableau][jsp]
    Par phileme dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 09/07/2004, 11h44
  5. [Debutant]contexte d'une Webapp servlet et jsp
    Par yahia dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 13/10/2003, 10h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo