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 :

Etat HTTP 500 - An exception occurred processing JSP page :org.apache.jasper.JasperException


Sujet :

Servlets/JSP Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2015
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2015
    Messages : 9
    Par défaut Etat HTTP 500 - An exception occurred processing JSP page :org.apache.jasper.JasperException
    Bonjour, je suis débutante en JEE et j'ai rencontré l'exception "org.apache.jasper.JasperException"
    pouvez vous m'aidez pour résoudre ce problème ?

    type: Rapport d''exception

    message: An exception occurred processing JSP page /produit.jsp at line 56

    description: Le serveur a rencontré une erreur interne qui l''a empêché de satisfaire la requête.

    exception:

    org.apache.jasper.JasperException: An exception occurred processing JSP page /produit.jsp at line 56

    53: <th>Etat</th>
    54: </tr>
    55: <%
    56: Iterator<Produit>list=produits.getList().iterator();
    57: while (list.hasNext())
    58: {
    59: Produit p= list.next();


    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)


    cause mère :

    java.lang.NullPointerException
    org.apache.jsp.produit_jsp._jspService(produit_jsp.java:122)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)


    et voici le code :

    <%@page import="java.util.Iterator"%>
    <%@page import="web.ProduitBeans"%>
    <%@page import="metier.Produit"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Gestion des produits</title>
    </head>
    <body>
    <%
    ProduitBeans produits = (ProduitBeans) request
    .getAttribute("modele");
    %>
    <h3>Tutoriel JEE (servlet, MVS, JDBC, JSP)</h3>
    <h5>Ajouter un nouveau produit</h5>
    <form action="prodserv" method="post">
    <table border="1" width="30%">
    <tr>
    <td>Nom</td>
    <td><input type="text" name="nom" /></td>
    </tr>

    <tr>
    <td>Description</td>
    <td><input type="text" name="desc" /></td>
    </tr>

    <tr>
    <td>Prix</td>
    <td><input type="text" name="prix" /></td>
    </tr>

    <tr>
    <td>Etat</td>
    <td><input type="text" name="etat" /></td>
    </tr>

    <tr>
    <td colspan="2"><input type="submit" value="valider" /></td>

    </tr>
    </table>
    </form>
    <table border="1" width="60%">
    <tr>
    <th>ID</th>
    <th>Nom</th>
    <th>Description</th>
    <th>Prix</th>
    <th>Etat</th>
    </tr>
    <%
    Iterator<Produit>list=produits.getList().iterator(); //ligne d'erreur
    while (list.hasNext())
    {
    Produit p= list.next();
    %>
    <tr>
    <td><%=p.getId() %></td>
    <td><%=p.getNom() %></td>
    <td><%=p.getDesc()%></td>
    <td><%=p.getPrix() %></td>
    <td><%=p.getEtat() %></td>
    </tr>

    <% } %>
    <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    </tr>
    </table>

    </body>
    </html>

  2. #2
    Membre Expert
    Avatar de eulbobo
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2003
    Messages
    786
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Par défaut
    Soit ton produit est null :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ProduitBeans produits = (ProduitBeans) request.getAttribute("modele")
    Soit la liste dans le produit est null
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Iterator<Produit>list=produits.getList().iterator();
    Met ta boucle en commentaire et essaye d'afficher le produit, puis la liste

  3. #3
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2015
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2015
    Messages : 9
    Par défaut
    Merci pour votre aide mais quand même j'ai pas pu résoudre le problème
    voici la servlet ça peut aider peut être
    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
     
    package web;
     
    import java.io.IOException;
    import java.io.PrintWriter;
     
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.catalina.connector.Request;
     
    import metier.Operation;
    import metier.Produit;
     
    public class ProduitServlet extends HttpServlet{
     
    	protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
     
    		//Recuperer les informations
    		String nom=req.getParameter("nom");
    		String desc=req.getParameter("desc");
    		String prix=req.getParameter("prix");
    		String etat=req.getParameter("etat");
    		//Création des objets
    		Produit p= new Produit(1l, nom, desc,Integer.parseInt(prix),Integer.parseInt(etat));
    		Operation op=new Operation();
    		ProduitBeans pb= new ProduitBeans();
    		//traitement
    		op.add(p);
    		pb.setList(op.getAll());
    		req.setAttribute("modele", pb);
    		req.getRequestDispatcher("produit.jsp").forward(req, resp);
                 }
    }

  4. #4
    Membre Expert
    Avatar de eulbobo
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2003
    Messages
    786
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Par défaut
    Peux tu nous donner le code qui correspond à Operation?
    Parce que à priori et de ce que j'en vois, on dirait que c'est la liste produits.getList() qui est null, ce qui voudrait dire que op.getAll() renvoie null dans ton cas.

  5. #5
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2015
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2015
    Messages : 9
    Par défaut
    Citation Envoyé par eulbobo Voir le message
    Peux tu nous donner le code qui correspond à Operation?
    Parce que à priori et de ce que j'en vois, on dirait que c'est la liste produits.getList() qui est null, ce qui voudrait dire que op.getAll() renvoie null dans ton cas.
    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
     
    package metier;
     
    import java.util.ArrayList;
     
    import com.sun.org.apache.bcel.internal.generic.RETURN;
     
    public class Operation {
     
    	private ArrayList<Produit> produits =new ArrayList<Produit>();
     
    	public ArrayList<Produit> getProduits() 
    	{
    		return produits;
    	}
     
    	public void setProduits(ArrayList<Produit> produits) 
    	{
    		this.produits=produits;
    	}
     
    	public void add(Produit p)
    	{
    		produits.add(p);
    	}
     
    	public void remove(Long id) 
    	{
    		for(Produit p:produits)
    		{
    			if(p.getId()==id)
    			{
    				produits.remove(p);
    				break;
    			}
    		}
    	}
     
    	public ArrayList getAll() 
    	{
    		return produits;
    	}
    }

  6. #6
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2015
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2015
    Messages : 9
    Par défaut
    Voici le reste du code si vous voulez:

    Operation:
    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
     
    package metier;
     
    import java.util.ArrayList;
     
    import com.sun.org.apache.bcel.internal.generic.RETURN;
     
    public class Operation {
     
    	private ArrayList<Produit> produits =new ArrayList<Produit>();
     
    	public ArrayList<Produit> getProduits() 
    	{
    		return produits;
    	}
     
    	public void setProduits(ArrayList<Produit> produits) 
    	{
    		this.produits=produits;
    	}
     
    	public void add(Produit p)
    	{
    		produits.add(p);
    	}
     
    	public void remove(Long id) 
    	{
    		for(Produit p:produits)
    		{
    			if(p.getId()==id)
    			{
    				produits.remove(p);
    				break;
    			}
    		}
    	}
     
    	public ArrayList getAll() 
    	{
    		return produits;
    	}
    }
    Produit:

    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
     
    package metier;
     
    public class Produit {
     
    	private Long id;
    	private String nom, desc;
    	private int prix,etat;
     
    	public Produit(String nom, String desc, int prix, int etat) {
    		super();
    		this.nom = nom;
    		this.desc = desc;
    		this.prix = prix;
    		this.etat = etat;
    	}
    	public Produit(Long id, String nom, String desc, int prix, int etat) {
    		super();
    		this.id = id;
    		this.nom = nom;
    		this.desc = desc;
    		this.prix = prix;
    		this.etat = etat;
    	}
    	public Produit() {
    		super();
    		// TODO Auto-generated constructor stub
    	}
    	public Long getId() {
    		return id;
    	}
    	public void setId(Long id) {
    		this.id = id;
    	}
    	public String getNom() {
    		return nom;
    	}
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
    	public String getDesc() {
    		return desc;
    	}
    	public void setDesc(String desc) {
    		this.desc = desc;
    	}
    	public int getPrix() {
    		return prix;
    	}
    	public void setPrix(int prix) {
    		this.prix = prix;
    	}
    	public int getEtat() {
    		return etat;
    	}
    	public void setEtat(int etat) {
    		this.etat = etat;
    	}
     
    	public String toString() {
     
    		return id + " - " + nom + " - " + desc + " - " + prix+ " - " + etat+ " . ";
    	}
     
    	public void show()
    	{
    		System.out.println(toString());
    	}
    }
    ProduiBeans:

    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
     
    package web;
     
    import java.util.ArrayList;
    import java.util.Vector;
     
    import metier.Produit;
     
    public class ProduitBeans 
    {
    	private Produit produit = new Produit();
    	private ArrayList<Produit> list = new ArrayList<Produit>();
     
    	public Produit getProduit() 
    	{
    		return produit;
    	}
     
    	public void setProduit(Produit produit) 
    	{
    		this.produit = produit;
    	}
     
    	public ArrayList<Produit> getList() 
    	{
    		return list;
    	}
     
    	public void setList(ArrayList arrayList) 
    	{
    		this.list = arrayList;
    	}
     
    }

  7. #7
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    salut,
    as-tu testé si la variable
    etait nullr?

    Eric

  8. #8
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2015
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2015
    Messages : 9
    Par défaut
    Merci pour votre aide mais quand même j'ai pas pu résoudre le problème
    voici la servlet ça peut aider peut être
    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
     
     
    package web;
     
    import java.io.IOException;
    import java.io.PrintWriter;
     
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.catalina.connector.Request;
     
    import metier.Operation;
    import metier.Produit;
     
    public class ProduitServlet extends HttpServlet{
     
    	protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
     
    		//Recuperer les informations
    		String nom=req.getParameter("nom");
    		String desc=req.getParameter("desc");
    		String prix=req.getParameter("prix");
    		String etat=req.getParameter("etat");
    		//Création des objets
    		Produit p= new Produit(1l, nom, desc,Integer.parseInt(prix),Integer.parseInt(etat));
    		Operation op=new Operation();
    		ProduitBeans pb= new ProduitBeans();
    		//traitement
    		op.add(p);
    		pb.setList(op.getAll());
    		req.setAttribute("modele", pb);
    		req.getRequestDispatcher("produit.jsp").forward(req, resp);
     
    	}
    }

Discussions similaires

  1. An exception occurred processing JSP page
    Par pitchu dans le forum Servlets/JSP
    Réponses: 4
    Dernier message: 03/03/2015, 17h09
  2. Réponses: 5
    Dernier message: 24/11/2014, 10h04
  3. Réponses: 1
    Dernier message: 17/01/2013, 11h42
  4. Réponses: 1
    Dernier message: 05/12/2009, 19h30
  5. Réponses: 2
    Dernier message: 27/08/2008, 09h32

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