I am making a simple Maven Project using Eclipse. There is a form that has Username and Password and a submit button.
When I enter and submit the default username(admin) and password(admin). It should either show a page with "Pass" or "Fail" text if they match. But when I submit the form it shows this error.
This is my file directory for the project.
I have installed the required dependency in the pom.xml file and got the servlet in the web.xml file as well. But I don't know why this issue is still there. I have tried other similar stack overflow solutions and from Google too but none of them worked so far.
index.jsp
Код: Выделить всё
Insert title here
JSP Page
Код: Выделить всё
Test Page
Код: Выделить всё
Test Page
Код: Выделить всё
package com.examSolution;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LoginServlet
*/
@WebServlet("/loginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username.equals("admin") && password.equals("admin")) {
response.sendRedirect("Success.jsp");
}else {
response.sendRedirect("Error.jsp");
}
}
}
Источник: https://stackoverflow.com/questions/781 ... or-the-tar