How to load a servlet on index.jsp

Is it possible to call a servlet on index.jsp? My welcome file index.jsp. I need to populate the dropdown list values ​​with a servlet when it index.jspopens.

I tried to install <load-on-startup>in web.xml, but it did not affect. How to get a welcome file index.jspto call a servlet?

+5
source share
3 answers

Just change the URL of the welcome file to the servlet.

Given this servlet mapping,

<servlet-mapping>
    <servlet-name>indexServlet</servlet-name>
    <url-pattern>/index</url-pattern>
</servlet-mapping>

just enter this list of welcome files:

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

/index.jsp /WEB-INF, , URL ( , /WEB-INF/index.jsp).

, " ", " ", URL, .

<servlet-mapping>
    <servlet-name>indexServlet</servlet-name>
    <url-pattern></url-pattern>
</servlet-mapping>

. :

+10

, .

, JSP.

Ajax, ajax- jsp, .

, ,

0

... ...

<% request.getRequestDispatcher( " " ). include (, );% > : <% request.getRequestDispatcher( "Alumni_Servlet = ?" ) (, );.% >

Servlet .

0

All Articles