You need to put the JSP file in /index.jsp
instead of in /WEB-INF/jsp/index.jsp
. This way the whole servlet is superflous by the way.
WebContent
|-- META-INF
|-- WEB-INF
| `-- web.xml
`-- index.jsp
If you're absolutely positive that you need to invoke a servlet this strange way, then you should map it on an URL pattern of /index.jsp
instead of /index
. You only need to change it to get the request dispatcher from request
instead of from config
and get rid of the whole init()
method.
In case you actually intend to have a "home page servlet" (and thus not a welcome file — which has an entirely different purpose; namely the default file which sould be served when a folder is being requested, which is thus not specifically the root folder), then you should be mapping the servlet on the empty string URL pattern.
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
See also Difference between / and /* in servlet mapping url pattern.