This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes Still getting same error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

Still getting same error

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">


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" >

and the java class which it calls is
package web;
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 {
PrintWriter writer = response.getWriter();
writer.println("Thank You, "+ username + ". You are now logged into the system.");
}catch (Exception e) {
but when I am deploying it it giving the error as

"HTTP method POST is not supported by this URL" can somebody explain this?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19750

Your HTML points to this URL: /Ch05/Login

And the code you pointed to is a servlet named: /web/Login

Now maybe you have a servlet mapping that connects that URL to that servlet. But I think it is more likely that you have another Login servlet somewhere that is the real problem.
Rahul Bajaj
Ranch Hand

Joined: Sep 21, 2004
Posts: 45
Thanks a worked. Actually I had 2 Login.class files. Thanks...I have been trying this since morning.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63350

Please continue the discussion in the original post.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Still getting same error
It's not a secret anymore!