N
N
Nikolay Baranenko2016-06-08 12:14:39
Java
Nikolay Baranenko, 2016-06-08 12:14:39

How to correctly access the webservlet?

Hello.

Trying to address servlet execution from jsp and getting HTTP Status 404 (Resource not available) error
using
@WebServlet("/ Login ")

JSP code

<body>
<h1>Выполните вход:</h1>
    <form method="post" action="Login" enctype="multipart/form-data">
    <table id="testTable1">

        <tr>
            <td>Имя пользователя:</td>
            <td><input type="text" name="username" size="20" /></td>
        </tr>
        <tr>
            <td>Пароль:</td>
            <td><input type="password" name="password" /></td>
        </tr>
    </table>
    <br>
    <input type="submit" value="Войти" />
</form>
</body>


servlet code

package RU.Servlet.HTTP;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
 *
 */
@WebServlet("/Login")
public class Login extends HttpServlet {
    private static final long serialVersionUID = 1L;
.....


Where is the mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolay Baranenko, 2016-06-09
@drno-reg

Problem solved, thanks for the help.

A
Alexander Kosarev, 2016-06-08
@jaxtr

  1. Is there an error in the URL specified in the form action?
  2. Does the servlet container you are using support @WebServlet?
  3. What is the URL of the form page?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question