tomcat says http method post is not supported by this url
up vote
0
down vote
favorite
i've been calling servlet by a HTML page and my servlet code goes like this:
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
public class validation extends HttpServlet
{
static PrintWriter pw = null;
public void doPost(HttpServletResponse response, HttpServletRequest request) throws ClassNotFoundException, SQLException, IOException, ServletException
{
pw = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
RequestDispatcher rd = request.getRequestDispatcher("new.html");
Class.forName("java.sql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/timetabledb", "root","`");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select password from users where username = '"+username+"';");
if(rs.next()==false)
{
pw.println("No such user found!");
}
else
{
if(password.equals(rs.getString("password")))
{
rd.forward(request, response);
}
else
{
pw.println("Invalid credentials!");
}
}
rs.close();
}
}
and my html page is this:
<!DOCTYPE html>
<html>
<head>
<title>Login Page - SGMS</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div id = "container">
<div class = "welcome-head">
Welcome
</div>
<div class = "sw-head">
Semi-Automatic Schedule Generator & Maintenance Software
</div>
<span class="logo">
<img src="logo.gif" alt="Logo"/>
</span>
<div class = "form">
<form method="POST" action="validation">
<label for="inp-usr" class="inp">
<input type="text" name="username" id="inp-usr" placeholder=" " required="required">
<span class="label">Username</span>
<span class="border"></span>
</label>
<br>
<label for="inp-pwd" class="inp">
<input type="password" name="password" id="inp-pwd" placeholder=" " required="required">
<span class="label">Password</span>
<span class="border"></span>
</label>
<br><br><br>
<button class="validate-btn" onclick="show();">
Validate
</button>
</form>
</div>
</div>
</body>
</html>
but the problem is that whenever i run all this, the application server says, that POST method isn't supported by this url.
I've experienced this error frequently, please explain why all this happens.
I've mapped the servlet in my web.xml
Thanks in advance.
java html tomcat web
add a comment |
up vote
0
down vote
favorite
i've been calling servlet by a HTML page and my servlet code goes like this:
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
public class validation extends HttpServlet
{
static PrintWriter pw = null;
public void doPost(HttpServletResponse response, HttpServletRequest request) throws ClassNotFoundException, SQLException, IOException, ServletException
{
pw = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
RequestDispatcher rd = request.getRequestDispatcher("new.html");
Class.forName("java.sql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/timetabledb", "root","`");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select password from users where username = '"+username+"';");
if(rs.next()==false)
{
pw.println("No such user found!");
}
else
{
if(password.equals(rs.getString("password")))
{
rd.forward(request, response);
}
else
{
pw.println("Invalid credentials!");
}
}
rs.close();
}
}
and my html page is this:
<!DOCTYPE html>
<html>
<head>
<title>Login Page - SGMS</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div id = "container">
<div class = "welcome-head">
Welcome
</div>
<div class = "sw-head">
Semi-Automatic Schedule Generator & Maintenance Software
</div>
<span class="logo">
<img src="logo.gif" alt="Logo"/>
</span>
<div class = "form">
<form method="POST" action="validation">
<label for="inp-usr" class="inp">
<input type="text" name="username" id="inp-usr" placeholder=" " required="required">
<span class="label">Username</span>
<span class="border"></span>
</label>
<br>
<label for="inp-pwd" class="inp">
<input type="password" name="password" id="inp-pwd" placeholder=" " required="required">
<span class="label">Password</span>
<span class="border"></span>
</label>
<br><br><br>
<button class="validate-btn" onclick="show();">
Validate
</button>
</form>
</div>
</div>
</body>
</html>
but the problem is that whenever i run all this, the application server says, that POST method isn't supported by this url.
I've experienced this error frequently, please explain why all this happens.
I've mapped the servlet in my web.xml
Thanks in advance.
java html tomcat web
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i've been calling servlet by a HTML page and my servlet code goes like this:
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
public class validation extends HttpServlet
{
static PrintWriter pw = null;
public void doPost(HttpServletResponse response, HttpServletRequest request) throws ClassNotFoundException, SQLException, IOException, ServletException
{
pw = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
RequestDispatcher rd = request.getRequestDispatcher("new.html");
Class.forName("java.sql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/timetabledb", "root","`");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select password from users where username = '"+username+"';");
if(rs.next()==false)
{
pw.println("No such user found!");
}
else
{
if(password.equals(rs.getString("password")))
{
rd.forward(request, response);
}
else
{
pw.println("Invalid credentials!");
}
}
rs.close();
}
}
and my html page is this:
<!DOCTYPE html>
<html>
<head>
<title>Login Page - SGMS</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div id = "container">
<div class = "welcome-head">
Welcome
</div>
<div class = "sw-head">
Semi-Automatic Schedule Generator & Maintenance Software
</div>
<span class="logo">
<img src="logo.gif" alt="Logo"/>
</span>
<div class = "form">
<form method="POST" action="validation">
<label for="inp-usr" class="inp">
<input type="text" name="username" id="inp-usr" placeholder=" " required="required">
<span class="label">Username</span>
<span class="border"></span>
</label>
<br>
<label for="inp-pwd" class="inp">
<input type="password" name="password" id="inp-pwd" placeholder=" " required="required">
<span class="label">Password</span>
<span class="border"></span>
</label>
<br><br><br>
<button class="validate-btn" onclick="show();">
Validate
</button>
</form>
</div>
</div>
</body>
</html>
but the problem is that whenever i run all this, the application server says, that POST method isn't supported by this url.
I've experienced this error frequently, please explain why all this happens.
I've mapped the servlet in my web.xml
Thanks in advance.
java html tomcat web
i've been calling servlet by a HTML page and my servlet code goes like this:
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
public class validation extends HttpServlet
{
static PrintWriter pw = null;
public void doPost(HttpServletResponse response, HttpServletRequest request) throws ClassNotFoundException, SQLException, IOException, ServletException
{
pw = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
RequestDispatcher rd = request.getRequestDispatcher("new.html");
Class.forName("java.sql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/timetabledb", "root","`");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select password from users where username = '"+username+"';");
if(rs.next()==false)
{
pw.println("No such user found!");
}
else
{
if(password.equals(rs.getString("password")))
{
rd.forward(request, response);
}
else
{
pw.println("Invalid credentials!");
}
}
rs.close();
}
}
and my html page is this:
<!DOCTYPE html>
<html>
<head>
<title>Login Page - SGMS</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div id = "container">
<div class = "welcome-head">
Welcome
</div>
<div class = "sw-head">
Semi-Automatic Schedule Generator & Maintenance Software
</div>
<span class="logo">
<img src="logo.gif" alt="Logo"/>
</span>
<div class = "form">
<form method="POST" action="validation">
<label for="inp-usr" class="inp">
<input type="text" name="username" id="inp-usr" placeholder=" " required="required">
<span class="label">Username</span>
<span class="border"></span>
</label>
<br>
<label for="inp-pwd" class="inp">
<input type="password" name="password" id="inp-pwd" placeholder=" " required="required">
<span class="label">Password</span>
<span class="border"></span>
</label>
<br><br><br>
<button class="validate-btn" onclick="show();">
Validate
</button>
</form>
</div>
</div>
</body>
</html>
but the problem is that whenever i run all this, the application server says, that POST method isn't supported by this url.
I've experienced this error frequently, please explain why all this happens.
I've mapped the servlet in my web.xml
Thanks in advance.
java html tomcat web
java html tomcat web
asked Nov 4 at 9:51
Gaurav Goswami
13
13
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You have made a mistake in your doPost
method. You have declared it as this:
void doPost(HttpServletResponse response, HttpServletRequest request)
throws ClassNotFoundException, SQLException, IOException, ServletException
but the correct signature is this:
void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
Notice the different parameter order ....
Since your method doesn't have the correct signature, it is not overriding the inherited version. That means that your version never gets called. Instead, a POST requests calls the inherited method ... and the behavior of that is to say "POST not supported".
Solution:
- Correct your
doPost
method's signature. (The exceptions will need fixing too!) - Add an
@Override
annotation to this ... and any other override methods in this class. - Get into the habit of always using
@Override
wherever you intend to override a method.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You have made a mistake in your doPost
method. You have declared it as this:
void doPost(HttpServletResponse response, HttpServletRequest request)
throws ClassNotFoundException, SQLException, IOException, ServletException
but the correct signature is this:
void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
Notice the different parameter order ....
Since your method doesn't have the correct signature, it is not overriding the inherited version. That means that your version never gets called. Instead, a POST requests calls the inherited method ... and the behavior of that is to say "POST not supported".
Solution:
- Correct your
doPost
method's signature. (The exceptions will need fixing too!) - Add an
@Override
annotation to this ... and any other override methods in this class. - Get into the habit of always using
@Override
wherever you intend to override a method.
add a comment |
up vote
1
down vote
You have made a mistake in your doPost
method. You have declared it as this:
void doPost(HttpServletResponse response, HttpServletRequest request)
throws ClassNotFoundException, SQLException, IOException, ServletException
but the correct signature is this:
void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
Notice the different parameter order ....
Since your method doesn't have the correct signature, it is not overriding the inherited version. That means that your version never gets called. Instead, a POST requests calls the inherited method ... and the behavior of that is to say "POST not supported".
Solution:
- Correct your
doPost
method's signature. (The exceptions will need fixing too!) - Add an
@Override
annotation to this ... and any other override methods in this class. - Get into the habit of always using
@Override
wherever you intend to override a method.
add a comment |
up vote
1
down vote
up vote
1
down vote
You have made a mistake in your doPost
method. You have declared it as this:
void doPost(HttpServletResponse response, HttpServletRequest request)
throws ClassNotFoundException, SQLException, IOException, ServletException
but the correct signature is this:
void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
Notice the different parameter order ....
Since your method doesn't have the correct signature, it is not overriding the inherited version. That means that your version never gets called. Instead, a POST requests calls the inherited method ... and the behavior of that is to say "POST not supported".
Solution:
- Correct your
doPost
method's signature. (The exceptions will need fixing too!) - Add an
@Override
annotation to this ... and any other override methods in this class. - Get into the habit of always using
@Override
wherever you intend to override a method.
You have made a mistake in your doPost
method. You have declared it as this:
void doPost(HttpServletResponse response, HttpServletRequest request)
throws ClassNotFoundException, SQLException, IOException, ServletException
but the correct signature is this:
void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
Notice the different parameter order ....
Since your method doesn't have the correct signature, it is not overriding the inherited version. That means that your version never gets called. Instead, a POST requests calls the inherited method ... and the behavior of that is to say "POST not supported".
Solution:
- Correct your
doPost
method's signature. (The exceptions will need fixing too!) - Add an
@Override
annotation to this ... and any other override methods in this class. - Get into the habit of always using
@Override
wherever you intend to override a method.
answered Nov 4 at 13:11
Stephen C
506k68552903
506k68552903
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139540%2ftomcat-says-http-method-post-is-not-supported-by-this-url%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password