tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julien Guiraud" <julien_guiraud_2...@yahoo.Fr>
Subject Problem with request dispatcher
Date Fri, 15 Jul 2005 00:35:20 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message