You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Julien Guiraud <ju...@yahoo.Fr> on 2005/07/15 02:35:20 UTC
Problem with request dispatcher
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