0

Ecplise say to me that I've an error in the web.xml page but I can't find it. This is the web.xml page

  <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    id="WebApp_ID" version="3.0">
    <display-name>UnogasApp</display-name>
    <filter-mapping>
       <filter-name>jdbcFilter</filter-name>
       <url-pattern>/*</url-pattern>
   </filter-mapping>

   <filter-mapping>
       <filter-name>cookieFilter</filter-name>
       <url-pattern>/*</url-pattern>
    </filter-mapping>
     <welcome-file-list>
     <welcome-file>home</welcome-file>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
     <welcome-file>default.html</welcome-file>
     <welcome-file>default.htm</welcome-file>
     <welcome-file>default.jsp</welcome-file>
     </welcome-file-list>
     </web-app>

When I try to run the code this is the error that occur: HTTP Status 404 – Not Found WEB-INF/views/homeView.jsp The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. I think because the servlet can't find the home String in the welcome-file. thanks

I add the servlet class

@WebServlet(urlPatterns = { "/home"})
public class HomeServlet extends HttpServlet {
   private static final long serialVersionUID = 1L;

   public HomeServlet() {
       super();
   }

   @Override
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {


       // Forward to /WEB-INF/views/homeView.jsp
       // (Users can not access directly into JSP pages placed in WEB-INF)
       RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/WEB-INF/views/homeView.jsp");

       dispatcher.forward(request, response);

   }

   @Override
   protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
       doGet(request, response);
   }

}
Roberto
  • 33
  • 2
  • 8
  • jsp files inside your WEB-INF folder are not accessible directly. That's why. Move to your root folder – Jonathan Laliberte Oct 24 '18 at 00:30
  • thanks but now it gives me the error Type Status Report Message /UnogasApp/ Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. – Roberto Oct 24 '18 at 07:45
  • there is also an error in deployment descriptor: Error Pages with an "X" on it. – Roberto Oct 24 '18 at 07:47
  • Now it works thanks @JonathanLaliberte – Roberto Oct 26 '18 at 09:53

1 Answers1

0

jsp files inside your WEB-INF folder are not accessible directly. That's why. Move to your root folder –

Roberto
  • 33
  • 2
  • 8