-1

my work consists on viewing a JSP page using servlets the problem is that Produit.jsp has worked normally while it didn't work for the SaisieProduit.jsp (so it wasn't a problem of web.xml), also when I run SaisieProduit.jsp without passing by the servlet class it worked normally.

here is my servlet class

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        String path=req.getServletPath();

        if(path.equals("/index.do")){
            req.getRequestDispatcher("produits.jsp").forward(req, resp);
        }
        else if(path.equals("/chercher.do")){
            String motCle=req.getParameter("motCle");

            ProduitModel model=new ProduitModel();
            model.setMotCle(motCle);            
            List<Produit> produits=new ArrayList<Produit>();
             produits=metier.produitsParMC(motCle);
            model.setProduits(produits);
            req.setAttribute("model", model);
            req.getRequestDispatcher("produits.jsp").forward(req, resp);

        }

        else if(path.equals("/saisie.do")){
            req.getRequestDispatcher("SaisieProduit.jsp").forward(req, resp);
        }



    }

}

here is the link of saisie.do

<div class="navbar navbar-default">
  <ul class="nav navbar-nav">
  <li><a href="index.do">Home</a></li>
  <li><a href="saisie.do">Saisie</a></li>
</ul>

</div>

when I click on saisie a blanket page appears

Ru Chern Chong
  • 3,692
  • 13
  • 33
  • 43
marouu
  • 17
  • 5

1 Answers1

0

I am guessing but String path=req.getServletPath(); would print only the URL you set in your servlet, so the conditions you are trying to work with wont trigger. Print your path-Variable and you can check that.

Here is a way to do what I understood you are trying to do: call servlet on link

rhenesys
  • 174
  • 1
  • 11