-4
I am having a 404 error on my login page.
I’m very beginner and so it’s probably a stupid question.
Maybe my mistake is on the way, but I can’t find it.
The. jsp reference is login.jsp
that you should call Login.java
that would have a Dispatch to config.jsp
- that is inside WEB-INF.
This is the project:
My call on login.jsp
<form method="post" action="/Login">
<input type="text" id="username" name="username" placeholder="Usuário">
<input type="password" id="password" name="password" placeholder="Senha">
<input type="submit" value="Entrar">
</form>
Man web.xml
:
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
Man Login.java
:
@WebServlet(urlPatterns = {"/Login"})
public class Login extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher dispatcher = getServletContext()
.getRequestDispatcher("/WEB-INF/config.jsp");
dispatcher.forward(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
HttpSession session = request.getSession(true);
if(username.equals("admin") && password.equals("admin")){
session.setAttribute("username", username);
doGet(request, response);
}
else {
response.sendRedirect("login.jsp");
}
};
Vitória, be very welcome to [pt.so]. See how to ask a good question? and how to create a [Mre], so you can elaborate a good question and avoid closures
– gleisin-dev
I do not understand, the question may have a "donkey" content but it is clear enough, in my view.
– Vitória Natália
Good.. by the amount of negative votes is not quite that! Oh, by the way, I’m not saying that the content is "dumb" just lacks some criteria of [Re].
– gleisin-dev