aspose file tools*
The moose likes Java in General and the fly likes Http method post not supported by this url Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Http method post not supported by this url" Watch "Http method post not supported by this url" New topic
Author

Http method post not supported by this url

Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

dopost should be doPost


My Blog: Down Home Country Coding with Scott Selikoff
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
Ok...So do i need to redeploy after changing that/
Abhijeet Thacker
Greenhorn

Joined: Jan 15, 2005
Posts: 16
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


Always code as if person who is going to maintain your code is a maniac serial killer and knows where you live
Sanjeev P Kulkarni
Greenhorn

Joined: Nov 08, 2009
Posts: 20

try this inside the servlet mapping tags just insert the POST parameter as shown below. It worked for me!


Sanjeev
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Http method post not supported by this url