I have repeated my test with a static html file and a simple servlet- the
call always goes to doGet(). Here are my html, java and web.xml files in
case you want to verify (please do):

<html>
<head>
<title>A Servlet Frontend</title>
</head>
<body>
<h2>A form with GET</h2>
<form method="GET" action="testServlet">
<input type=submit>
</form>
<h2>A form with POST</h2>
<form method="POST" action="testServlet">
<input type=submit>
</form>
</body>
</html>


import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MethodTestServlet extends HttpServlet {
  public void init(ServletConfig conf) throws ServletException {
    super.init(conf);
  }
  public void doGet (HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
      res.getWriter().print("this was a GET request");
  }
  public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
  {
      res.getWriter().print("this was a POST request");
  }
}

<?xml version="1.0"?>
<!DOCTYPE web-application SYSTEM "web-application.dtd">
<web-app>
    <display-name>J2EETest</display-name>
    <description>first J2EE Orion Test</description>
    <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>MethodTestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/testServlet/*</url-pattern>
    </servlet-mapping>
</web-app>




Reply via email to