0

I have servlet of registration.

@WebServlet("/register")
public class RegisterServlet extends HttpServlet {
...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("in servlet");
}
}

If I go to that page I get

HTTP Status 404 -

type Status report

message

description The requested resource is not available.

Apache Tomcat/8.0.36

If I change @WebServlet("/register") in @WebServlet("/register1") all works correctly. How do I fix this situation?

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">
    <display-name>booker</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>pages/index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <context-param>
        <param-name>controllers</param-name>
        <param-value>com.epam.task.controller</param-value>
    </context-param>

    <session-config>
        <session-timeout>-1</session-timeout>
    </session-config>



</web-app>
VolBog
  • 13
  • 3

2 Answers2

0

Please check the web.xml and change the servlet name and url to register. Or kindly upload the web.xml too.

0

Please check from action in your jsp ,it might be incorrect.

Kaustubh
  • 64
  • 1
  • 7
  • I dont forward to jsp. Only do action on servlet. – VolBog Sep 03 '16 at 11:53
  • ok ...please post from where you want to call this servlet . – Kaustubh Sep 03 '16 at 12:06
  • http://localhost:8080/booker/register its addres where I call this servlet. and when I change @WebServlet("/register1") and call http://localhost:8080/booker/register1 all works. – VolBog Sep 03 '16 at 12:22