Live Traffic

Our Story

Ceremony

Search

Just Married

JSP Initialization

by - March 30, 2010

<?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-name>InitializationJSP</servlet-name>
<jsp-file>/initialization.jsp</jsp-file>
<init-param>
<param-name>testParam</param-name>
<param-value>hello from web.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>InitializationJSP</servlet-name>
<url-pattern>/Initialization</url-pattern>
</servlet-mapping>
</web-app>

//File: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>

You May Also Like

0 comments