-2

I have servlet A where there is this code :

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    RequestDispatcher rd = request.getRequestDispatcher("gestion-avis");
    rd.forward(request, response);

}

And then another servlet B which refers to "gestion-avis" :

@WebServlet("/gestion-avis")
public class GestionAvisServlet extends HttpServlet

The code of the A servlet normally redirect to the doGet method of the servlet B.

But this redirect me to an empty html page called "gestion-avis".

Thank you for your help !

jozinho22
  • 459
  • 2
  • 7
  • 24

1 Answers1

0

This could be the reason for your issue.

Since you are forwarding request to another servlet mapped at url gestion-avis, the request goes to your GestionAvisServlet and its doGet method.

Now if your GestionAvisServlet.doGet method is not writing any data to HttpServletResponse, you will get a blank screen.

So to see some data either you need to write data to HttpServletResponse like this:

public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException {
        response.getWriter().println("Hello");
 }

Otherwise you can forward to another page.

Chaitanya
  • 15,403
  • 35
  • 96
  • 137