• Post Reply Bookmark Topic Watch Topic
  • New Topic

Http method post not supported by this url  RSS feed

 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
</head>

<body>
<h1>Login</h1>

Please enter your username and password
<form action="/Ch05/Login" method="POST">
<p><input type="text" name="username" length="40">
<p><input type="password" name="password" length="40">
<p><input type="submit" value="Submit" >
</form>
</body>
</html>

and the java class which it calls is
package web;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Login extends HttpServlet {
public void dopost(HttpServletRequest request, HttpServletResponse response)
{ String username = request.getParameter("username");
try {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html><body>");
writer.println("Thank You, "+ username + ". You are now logged into the system.");
writer.println("</body></html>");
writer.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}
but when I am deploying it it giving the error as

"HTTP method POST is not supported by this URL" can somebody explain this?
 
Scott Selikoff
author
Bartender
Posts: 4087
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dopost should be doPost
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...So do i need to redeploy after changing that/
 
Abhijeet Thacker
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope that you have already got the answer of your last question. Just to clarify u need to redeploy your application if you make ANY change in ur classes. This is not the case with jsp files or html files.

hth
 
Sanjeev P Kulkarni
Greenhorn
Posts: 20
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this inside the servlet mapping tags just insert the POST parameter as shown below. It worked for me!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!