action формы не взаимодействует с сервлетом
Начал изучать сервлеты, форма(с html страницы) не отправляет данные на указанный url, притом сам сервлет работает(проверял через postman). Сервлет:
@WebServlet( value = "/security"
)
public class ValidationServlet extends HttpServlet {
private MainService service;
public ValidationServlet(){
service = new MainService();
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
ValidationObject object =service.getUser(req.getParameter("login"),req.getParameter("password"));
switch (object.getNumber()){
case 0 -> resp.setStatus(403);
default -> {
getServletContext().getRequestDispatcher("/WEB-INF/classes/static/Profile.html").forward(req,resp);
}
}
}
}
Форма:
<form action="security" method="get">
<div class="col-4">
<div class="form-group">
<label for="login">enter your email there</label>
<input type="text" class="form-control" name="login" id="login" aria-describedby="emailHelpId" placeholder="">
<small id="emailHelpId" class="form-text text-muted">Help text</small>
</div>
</div>
<div class="w-100"></div>
<div class="col-4">
<div class="form-group">
<label for="password">enter your password here</label>
<input type="password" class="form-control" name="password" id="password" placeholder="">
</div>
</div>
<button type="submit" class="btn btn-primary" >Log in</button>
</form>
Расположение директорий:
Ответы (1 шт):
Автор решения: handsome16
→ Ссылка
Проблема оказалась в том, что я запускал статические страницы отдельно в директории, а не на сервере, решил, спасибо tym32167
