web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>
The name of the application
</display-name>
<description>
C'mon, you know what goes into a description, don't you?
</description>

<context-param>
<param-name>name_of_context_initialization_parameter</param-name>
<param-value>value_of_context_initializtion_parameter</param-value>
<description> Again, some description </description>
</context-param>

<servlet>
<servlet-name>guess_what_name_of_servlet</servlet-name>
<description>Again, some description</description>
<servlet-class>com.foo-bar.somepackage.TheServlet</servlet-class>
<init-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>name_of_a_servlet</servlet-name>
<url-pattern>*.some_pattern</url-pattern>
</servlet-mapping>

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

<session-config>
<session-timeout>30</session-timeout>
</session-config>

</web-app>


context-param

The values within the context-param element can be accessed like so:

String value = getServletContext().getInitParameter("name_of_context_initialization_parameter");

Servlet initialization parameters (that is: the values within the servlet element) can be retrieved in a servlet or JSP page by calling:

String value = getServletConfig().getInitParameter("foo");

session-timeout

<session-timeout>: The timeout for a session in minutes.

servlet

For each servlet in the web application, there is a <servlet> element. The name identifies the servlet (<servlet-name>).

servlet-mapping

Each servlet in the web application gets a servlet mapping. The url pattern is used to map URI to servlets.

Obviously, the order of the elements matters!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值