Gremlin92
@Gremlin92
Целеустремленный

Работает не понимаю как?

Вообщем есть такие файлы в C:\Users\User\Desktop\Tropic-Island\Tropic-Island\Java\apache_tomcat\apache-tomcat-8.5.23\webapps\ROOT edit.jsp,index2.jsp,notfound.jsp,create.jsp
захожу на localhost:8080/index2.jsp
вот его содержимое
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Users</title>
</head>
<body>
<h2>Users List</h2>
<p><a href='<c:url value="/create" />'>Create new</a></p>
<table>
<tr><th>NickName</th><th>Password</th><th>email</th></tr>
<c:forEach var="user" items="${users}">
 <tr>
    <td>${user.nickname}</td> 
    <td>${user.password}</td>
    <td>${user.email}</td>
    <td>
    <a href='<c:url value="/edit?id=${user.id}" />'>Edit</a> |
    <form method="post" action='<c:url value="/delete" />' style="display:inline;">
        <input type="hidden" name="id" value="${user.id}">
        <input type="submit" value="Delete">
    </form>
 </td></tr>
</c:forEach>
</table>
</body>
</html>

вот сервлет IndexServlet.java
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author User
 */
@WebServlet("/")
public class IndexServlet extends HttpServlet {
     
    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException {
        ArrayList<Users> users = UsersDB.select();
        request.setAttribute("users",users);
          
        getServletContext().getRequestDispatcher("/index2.jsp").forward(request, response);
    }
}

жму ссылку create new, вылазит 404 not found.
если закинуть эти же файлы в C:\Users\User\Desktop\Tropic-Island\Tropic-Island\Java\apache_tomcat\apache-tomcat-8.5.23\webapps\Example то все работает, кроме того, что вначале при загрузки localhost:8080/index2.jsp не отображается список пользователей из бд,потом конечно перебрасывает при создании(надо создать) на список всех
остальные файлы до кучи
create.jsp
\
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Create User</title>
</head>
<body>
<h3>New User</h3>
<form method="post">
<label>NickName</label><br>
<input name="nickname"/><br><br>
<label>Password</label><br>
<input name="password" /><br><br>
<label>Email</label><br>
<input name="email" /><br><br>
<input type="submit" value="Save" />
</form>
</body>
</html>

edit.jsp
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Edit Users</title>
</head>
<body>
<h3>Edit Users</h3>
<form method="post">
<input type="hidden" value="${users.id}" name="id" />
<label>NickName</label><br>
<input name="nickname" value="${users.nickname}" /><br><br>
<label>Password</label><br>
<input name="password" value="${users.password}" /><br><br>
<label>Email</label><br>
<input name="email" value="${users.email}" /><br><br>
<input type="submit" value="Send" />
</form>
</body>
</html>

notfound.jsp
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Page not found</title>
</head>
<body>
<h2>Page not found</h2>
</body>
</html>

классы скомпилированные лежат по адресу C:\Users\User\Desktop\Tropic-Island\Tropic-Island\Java\apache_tomcat\apache-tomcat-8.5.23\webapps\Example\WEB-INF\classes
CreateServlet.java,IndexServlet.java,DeleteServlet.java,EditServlet.java,Users.java,UsersDB.java не могу выложить они много знаков занимают, лежат вот тут https://github.com/Beginerok/Tropic-Island/tree/ma...
  • Вопрос задан
  • 175 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы