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

  1. #1
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    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 chevronné
    Avatar de eulbobo
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2003
    Messages
    786
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    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
    Je ne suis pas mort, j'ai du travail !

  3. #3
    Membre chevronné 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
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    as-tu testé si la variable
    etait nullr?

    Eric

  4. #4
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    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);
     
    	}
    }

  5. #5
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    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);
                 }
    }

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

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    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.
    Je ne suis pas mort, j'ai du travail !

  7. #7
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    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;
    	}
    }

  8. #8
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    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;
    	}
     
    }

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

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    Par défaut
    Rien qui me saute aux yeux...

    Tu peux essayer avec cette JSP et nous dire ce que ça te raconte?

    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
     
    <%@page import="web.ProduitBeans"%>
    <%@ 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>
     
    Produit --|
    <%
    ProduitBeans produits = (ProduitBeans) request.getAttribute("modele");
     
    out.println(produits);
     
    %>
    |--
     
    </body>
    </html>
    Je ne suis pas mort, j'ai du travail !

  10. #10
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    Par défaut
    Voici le résultat:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Produit --| null |--

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

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    Par défaut
    Donc c'est bien ton objet que tu essayes de mettre en requête dans ta servlet que tu ne récupères pas dans la JSP.

    Ce qui peut vouloir dire que tu ne passes pas dans ta méthode doPost.

    Essayes ça, et si ça marche, ça veut dire que l'URL qui te permet d'accéder à ta servlet est appelée en get et pas en post

    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
     
    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 doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
    		doPost(req, resp);
    	}
     
    	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);
                 }
    }
    Je ne suis pas mort, j'ai du travail !

  12. #12
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    Par défaut
    Toujours la même erreur, mais je viens juste de trouver cette solution, la voici

    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
     
     
    <%@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;
                    if (request.getAttribute("modele") != null) {
                            produits = (ProduitBeans) request.getAttribute("modele");
                    } else {
                            produits = new ProduitBeans();
                    }
    %>
    <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>
    et ça marche, je vous remercie infiniment.

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

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    Par défaut
    Juste pour ma culture, tu y accédais avec quelle adresse à ta JSP pour avoir ton message d'erreur?
    Je ne suis pas mort, j'ai du travail !

  14. #14
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    Par défaut
    Si j'ai bien compris votre question l'adresse est : http://localhost:8080/GestionProduit/produit.jsp

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

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2003
    Messages : 786
    Points : 1 993
    Points
    1 993
    Par défaut
    Citation Envoyé par meriem_tns Voir le message
    Si j'ai bien compris votre question l'adresse est : http://localhost:8080/GestionProduit/produit.jsp
    Si tu y accèdes comme ça, c'est normal que ProduitsBean soit null : tu accèdes directement à la page avant qu'elle ait été chargée par ta servlet.

    Plusieurs écoles et pratiques s'opposent, mais pour avoir testé plusieurs designs différents, je trouve que la technique qui consiste à ne jamais appeler directement les JSP est une bonne méthode : ça te force à mettre ta logique métier et navigation au niveau de ton controleur, et les JSP sont de simples vues qui ne font que présenter des données.

    Et pour être sûr de ne pas pouvoir appeler les JSP, le plus simple est de les mettre dans un sous-répertoire de WEB-INF
    Je ne suis pas mort, j'ai du travail !

  16. #16
    Nouveau Candidat au 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
    Points : 1
    Points
    1
    Par défaut
    Merci de votre aide et de votre conseil.

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