Set JSP location for servlet

I have a simple JSP based web application. The root of the application is as follows:

|
|--META-INF
|--WEB-INF
|  `--web.xml
|--img
|--css
|--index.jsp
|--some1.jsp
|--some2.jsp
|--some3.jsp

Where web.xml contains the lines below:

<servlet>
    <servlet-name>servlet-jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>servlet-jsp</servlet-name>
    <url-pattern>/*.jsp</url-pattern>
</servlet-mapping>

Now I want to change the file structure of the project - move all * .jsp files to a special directory:

|
|--META-INF
|--WEB-INF
|  `--web.xml
|--img
|--css
|--jsp
   |--index.jsp
   |--some1.jsp
   |--some2.jsp
   |--some3.jsp

Can I configure "servlet-jsp" to handle jsp / some1.jsp when the URL "/some1.jsp" is requested?

+3
source share
3 answers

, (?) *.jsp ( ) JSP, - , JSP. : -.

JSP / /jsp , . . , , JSP Servlet, , [re] .

+3

, /jsp/, JSP, request.getRequestDispatcer(targetJsp).forward()

+1
<servlet-mapping>
    <servlet-name>servlet-jsp</servlet-name>
    <url-pattern>/jsp/*.jsp</url-pattern>
</servlet-mapping>

, .

0
source

Source: https://habr.com/ru/post/1776726/


All Articles