RequestDispatcher forwarding redirected back to the same servlet

I have a servlet called User.java. It maps to a URL pattern

    <servlet-mapping>
        <servlet-name>User</servlet-name>
        <url-pattern>/user/*</url-pattern>
    </servlet-mapping>

Inside the servlet, the path following the slash is analyzed user/, the data about this user is extracted from the database, set in the attributes, and then the page is displayed user_home.jsp. Code for this:

            User user = UserManager.getUserInfoById(userPath);  
            request.getSession().setAttribute("user", user);
            request.getRequestDispatcher("resources/jsp/user_home.jsp").forward(request, response);

The problem is that instead of opening this, the user_home.jsprequest is again mapped to the same servlet User.java. He does not do anything.

I put the output statements at the beginning of the method doGet, so I see that the URL

http://localhost:8080/myproj/user/resources/jsp/user_home.jsp

therefore, it seems an obvious problem that it will return to the template user/*.

, URL-, jsp ?

+4
2

, request.getRequestDispatcher(), "/" , . /user/<something>, /user/resources/jsp/user_home.jsp, , , .

, , request.getRequestDispatcher(), "/" , . , resources webapp, "/" , :

request.getRequestDispatcher("/resources/jsp/user_home.jsp").forward(request, response);
+2

* . , , /user/ URL, .

URL, /user/, ,

<servlet-mapping>
        <servlet-name>User</servlet-name>
        <url-pattern>/user/User</url-pattern>
    </servlet-mapping>

action action = user/User

+1

All Articles