Problem with request dispatcher

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem with request dispatcher

Julien Guiraud
Hello,
 
i'm having a problem with calling a  servlet
and dispatching to a jsp.

my example:
here is my simple html form:

<html>
<body>
<form method="post" action="test">
Login <input type="text" name="login">

Password <input type="text" name="password">

<input type="submit" value="Envoyer">
</form>
</body>
</html>



Here's my processing servlet:
public class Test2 extends HttpServlet
{
 
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        System.err.println("test:  doGet()");
        getServletContext().getRequestDispatcher("/index2.jsp").forward(request, response);
                return;
    }
 
        public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
{
    System.err.println("test: doPost()");
    getServletContext().getRequestDispatcher("/index2.jsp").forward(request, response);
        return;
}
}
[/code
 
Here's index2.jsp code:
[code]
<html>
<head>
<title></title>
</head>
<body>
test
</body>
</html>



The logs of the server Tomcat 5.5 on W2K and IE 6 with a single form submit:
test: doPost()
test: doGet()

When i remove doGet implementation from the servlet, there is only
"test: doPost()" log. So it's OK.
When the two methods are implemented, that doesn't work good.

When i remove getRequestDispatcher... line in the doPost() method, it works.

I don't understand.

it happens every time with this example.

Thanks for your help

Julien