mardi 28 juin 2016

Tomcat - The requested resource is not available - IntelliK IDEA - Java EE

I created simple servlet named SimpleServlet and I try to link jsp page with it:

        String varTextA = "Hello World!";
        String varTextB = "It's JSP.";

        request.setAttribute("textA", varTextA);
        request.setAttribute("textB", varTextB);

        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
        dispatcher.forward(request, response);

But Tomcat 9 show me this:

HTTP Status 404 - /index.jsp

type Status report

message /index.jsp

description The requested resource is not available.

My project tree:

├── FirstJavaEEProject.iml
├── out
│   ├── artifacts
│   │   └── simple_mod_war_exploded
│   │       ├── index.jsp
│   │       └── WEB-INF
│   │           ├── classes
│   │           │   └── servlets
│   │           │       └── SimpleServlet.class
│   │           └── web.xml
│   └── production
│       └── simple-mod
│           └── servlets
│               └── SimpleServlet.class
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── servlets
│   │   │       └── SimpleServlet.java
│   │   └── resources
│   └── test
│       └── java
├── target
│   ├── classes
│   │   └── servlets
│   │       └── SimpleServlet.class
│   ├── first-java-ee-1.0-SNAPSHOT
│   │   ├── META-INF
│   │   │   └── MANIFEST.MF
│   │   └── WEB-INF
│   │       ├── classes
│   │       │   ├── servlets
│   │       │   │   └── SimpleServlet.class
│   │       │   └── webapp
│   │       ├── lib
...
│   │       └── web.xml
│   ├── first-java-ee-1.0-SNAPSHOT.war
│   ├── generated-sources
│   │   └── annotations
│   ├── maven-archiver
│   │   └── pom.properties
│   ├── maven-status
│   │   └── maven-compiler-plugin
│   │       ├── compile
│   │       │   └── default-compile
│   │       │       ├── createdFiles.lst
│   │       │       └── inputFiles.lst
│   │       └── testCompile
│   │           └── default-testCompile
│   │               └── inputFiles.lst
│   └── surefire
└── web
    ├── index.jsp
    └── WEB-INF
        └── web.xml

My web.xml:

<?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_3_1.xsd"
         version="3.1">

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>simple</servlet-name>
        <servlet-class>servlets.SimpleServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>simple</servlet-name>
        <url-pattern>/simple</url-pattern>
    </servlet-mapping>
</web-app>

Aucun commentaire:

Enregistrer un commentaire