Error ->
HTTP Status 405 - HTTP method GET is not supported by this URL type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource.
web.xml
<!-- webapp/WEB-INF/web.xml -->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>To do List</display-name>
<welcome-file-list>
<welcome-file>login.do</welcome-file>
</welcome-file-list>
</web-app>
LoginServlet.java
package com.todo;
//imports ->
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// url ->
@WebServlet(urlPatterns = "/login.do")
// response genrator ->
public class LoginServlet extends HttpServlet{
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {{
// JSP code response ->
RequestDispatcher RequetsDispatcherObj =request.getRequestDispatcher("/WEB-INF/veiws/login.jsp");
RequetsDispatcherObj.forward(request, response); }
}
}
login.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>hello world from jsp</title>
</head>
<body>
<p>
Hello world from jsp!
</p>
</body>
</html>