I have a servlet called User.java
. It is mapped to the url pattern
<servlet-mapping>
<servlet-name>User</servlet-name>
<url-pattern>/user/*</url-pattern>
</servlet-mapping>
Inside the Servlet, the path following the slash in user/
is analyzed, data about that user is retrieved from the database, set in attributes, and then the page user_home.jsp
is to be displayed.
The code to make this happen is:
User user = UserManager.getUserInfoById(userPath);
request.getSession().setAttribute("user", user);
request.getRequestDispatcher("resources/jsp/user_home.jsp").forward(request, response);
The problem is, that rather than opening this user_home.jsp
, the request is mapped once again to the same servlet User.java
. It does nothing.
I've put output statements at the beginning of the doGet
method, so I can see that the URL is
http://localhost:8080/myproj/user/resources/jsp/user_home.jsp
so it seems the obvious problem is that it's mapping right back to the user/*
pattern.
How do I get the Servlet to display this page without going through URL mapping, and properly display the jsp
I need it to?