I have jsp file named index.jsp
in root folder (webcontent), till now I simply used to access the page using the following URL:
Where Sample is the project name.
Now I was asked to change the URL pattern to the following without changing the location of index.jsp file (i.e. still the index.jsp be under webcontent folder):
How to achieve this by configuring the web.xml?
This can be achieved by the following way
<servlet>
<servlet-name>BeerAppServlet</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>BeerAppServlet</servlet-name>
<url-pattern>/test/index.jsp</url-pattern>
</servlet-mapping>
In <servlet>
instead of mapping it to <servlet-class>
map it to <jsp-file>