Проблема с сервлетами (servlet). Не открывается jsp файл
Не могу разобраться с url паттернами сервлетов. Не открывается страница user_list.jsp, я думаю, проблема в сервлетах. Но, в Eclipse и Tomcat эта страница открывается без проблем и все работает, но тот же самый код не работает в Intellij и Glassfish. Именно эта страница не открывается.
Вот код сервлета страницы админа. AdminHomeServlet.java:
@WebServlet("/admin/")
public class AdminHomeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public AdminHomeServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String homePage = "index.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(homePage);
dispatcher.forward(request,response);
}
}
Вот сама страница админа и она открывается. index.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Evergreen BookStore Administration</title>
</head>
<body>
<jsp:directive.include file="header.jsp" />
<div align="center">
<h2>Administrative Dashboard</h2>
</div>
<div align="center">
<hr width="60%" />
<h2> Quick Actions:</h2>
<b>
<a href="create_book">New Book</a>
<a href="create_user">New User</a>
<a href="create_category">New Category</a>
<a href="create_customer">New Customer</a>
</b>
</div>
<div align ="center">
<h2>Recent Sales:</h2>
</div>
<div align ="center">
<h2>Recent Reviews:</h2>
</div>
<div align ="center">
<h2>Statistics:</h2>
</div>
<jsp:directive.include file="footer.jsp" />
</body>
</html>
Вот сервлет, который не работает. ListUsersService.java:
@WebServlet("/admin/list_users")
public class ListUsersService extends HttpServlet {
public ListUsersService(){
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UserService userServices = new UserService();
List<Users> listUsers = userServices.listUser();
request.setAttribute("listUsers", listUsers);
String listPage = "user_list.jsp";
RequestDispatcher requestDispatcher = request.getRequestDispatcher(listPage);
requestDispatcher.forward(request, response);
}
}
Вот страница, которую должен открыть сервлет. user_list.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Manage Users - Evergreen BookStore Administration</title>
</head>
<body>
<jsp:directive.include file="header.jsp" />
<div align="center">
<h2>Users Management</h2>
</div>
<div align="center">
<hr width="60%" />
<h3><a href="">Create New User</a></h3>
<div align="center">
<table border="1" cellpadding="5">
<tr>
<th>Index</th>
<th>ID</th>
<th>Email</th>
<th>Full Name</th>
<th>Actions</th>
</tr>
<c:forEach var="user" items="${listUsers}" varStatus="status">
<tr>
<td>${status.index + 1}</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</c:forEach>
</table>
</div>
<jsp:directive.include file="footer.jsp" />
</body>
</html>
Почему в Eclipse and Tomcat открывается, а в IntelliJ and Glassfish не работает? В чем я ошибся? Спасибо!
