Issue Details
Submitting the form gives error: HTTP Status 405 – Method Not Allowed.
Url of html page: http://localhost:8080/java_servlet_practise_1/auth/login/login.html
Url of posted page: http://localhost:8080/java_servlet_practise_1/authenticate
HTML
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="/java_servlet_practise_1/authenticate">
<input type="text"/>
<input type="submit" value="Submit" />
</form>
</body>
</html>
Servlet
package com.auth.login;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class LoginServlet extends HttpServlet {
public void Service(HttpServletRequest request, HttpServletResponse response) {
System.out.println("this is login page.");
}
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>loginPage</servlet-name>
<servlet-class>com.auth.login.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>loginPage</servlet-name>
<url-pattern>/authenticate</url-pattern>
</servlet-mapping>
</web-app>
Directory Structure