| Author |
Post / Get
|
Nick Lebian
Greenhorn
Joined: May 30, 2003
Posts: 9
|
|
Hi! What must I change, if I want to use doPost instead of doGet? I'm using tomcat and my little test-programm looks like this: import javax.servlet.http.*; import javax.servlet.*; import java.io.*; public class HitServlet extends HttpServlet { private int mCount; public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { String message = "Hits: " + ++mCount; // response.setContentType("text/plain"); // response.setContentLength(message.length()); // PrintWriter out = response.getWriter(); // out.println(message); } } But the programm only runs with the doGet method, with the doPost method the browser shows this error message: HTTP method GET is not supported by this URL Why? Thanks. Bye, Nick
|
 |
Calina Cazangiu
Ranch Hand
Joined: Feb 27, 2003
Posts: 30
|
|
|
Add a doPost method where you could call doGet.
|
 |
Calina Cazangiu
Ranch Hand
Joined: Feb 27, 2003
Posts: 30
|
|
|
Maybe I misunderstood your question - it complains when you have a doPost but no doGet? Then it's the way you call the servlet. If you call the servlet directly from your browser, the default method is doGet. If you want to use doPost, use an html file where you specify method="POST" (again, get is the default)
|
 |
 |
|
|
subject: Post / Get
|
|
|