This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes HTTP method POST is not supported by this URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP method POST is not supported by this URL" Watch "HTTP method POST is not supported by this URL" New topic
Author

HTTP method POST is 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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Check your casing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
Do you mean doPost or dopost? Do I need to redeploy after changing that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

How would the change be picked up if you don't?
 
Consider Paul's rocket mass heater.
 
subject: HTTP method POST is not supported by this URL