2021年4月5日星期一

jsp servlet can't show up using intelling ide and tomcat

I can't open my jsp file even though I had configured the ward exploded and tomcat server using servlet controllers . I tried to look on different error in stackoverflow and other websites but couldn't really find the appropriate error solver.

import javax.servlet.ServletException;  import javax.servlet.http.HttpServlet;  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletResponse;  import java.io.IOException;  import java.util.List;    public class ControleurServlet extends HttpServlet {      private IAccountDAO account;        @Override      public void init()  {          account = new AccountDAOImpl();      }        @Override      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {          String path = req.getServletPath();          if (path.equals("/index.php")) {              req.getRequestDispatcher("Accounts.jsp").forward(req, resp);          }          else if (path.equals("/search.php")){              String keyWord=req.getParameter("keyWord");              AccountModel model=new AccountModel();              model.setKeyword(keyWord);              List<Account> accounts= account.accountsValues("%"+keyWord+"%");              model.setAccounts(accounts);              req.setAttribute("model",model);              req.getRequestDispatcher("Accounts.jsp").forward(req,resp);          }   }   }  

and here's my jsp file

<%@ page contentType="text/html;charset=UTF-8" language="java" %>  <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>  <html>  <head>      <title>Accounts</title>      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">  </head>  <body>  <%@include file="header.jsp" %>>  <div class="container col-md-10 col-md-offset-1">      <div class="panel panel-primary">          <div class="panel-heading">Search Users:</div>          <div class="panel-body">              <form action="search.php" method="get">                  <label>Keyword</label>                  <input type="text" name="keyWord">                  <button type="submit" class="btn btn-primary">Search</button>              </form>              <table class="table">                  <tr>                      <th>User_Id</th><th>Creation_Date</th><th>Username</th><th>Password</th>                  </tr>                  <c:forEach items="${model.account}" var="acc">                      <tr>                          <td>${acc.user_id}</td>                          <td>${acc.creation_date}</td>                          <td>${acc.username}</td>                          <td>${acc.password}</td>                          <td><a onclick="return confirm("Are you sure?")" href="delete.php?id=${acc.user_id}">delete</a> </td>                          <td><a href="Edit.php?id=${acc.user_id}">Edit</a> </td>                      </tr>                  </c:forEach>              </table>          </div>      </div>  </div>  </body>  </html>  

It keeps showing me the 404 error while trying to open my http://localhost:3030/Banque_war_exploded/test.php, and here's my web.xml file too

<?xml version="1.0" encoding="UTF-8"?>  <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"           version="4.0">      <display-name>Banque</display-name>      <servlet>          <servlet-name>cs</servlet-name>          <servlet-class>couche.presentation.ControleurServlet</servlet-class>      </servlet>      <servlet-mapping>          <servlet-name>cs</servlet-name>          <url-pattern>*.php</url-pattern>      </servlet-mapping>  </web-app>  
https://stackoverflow.com/questions/66962986/jsp-servlet-cant-show-up-using-intelling-ide-and-tomcat April 06, 2021 at 01:09PM

没有评论:

发表评论