Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

JSP: Initialisation en JSP

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
  <servlet-nom>InitializationJSP</servlet-nom>
  <jsp-file>/initialization.jsp</jsp-file>
  <init-param>
    <param-nom>testParam</param-nom>
    <param-value>hello from web.xml</param-value>
  </init-param>
</servlet>
<servlet-mapping>
  <servlet-nom>InitializationJSP</servlet-nom>
  <url-pattern>/Initialization</url-pattern>
</servlet-mapping>
</web-app>
 
//Fichier:initialization.jsp
<html>
<head>
<title>Initialization Parameters and JSP</title>
</head>
<body>
This page has retrieved the following initialization parameter from web.xml:
<br>
<%= pageContext.getServletConfig().getInitParameter("testParam") %>
</body>
</html>