10/12/2009

A sample web.xml (servlet 2.5)

This is a sample web.xml based on Servlet 2.5 (part of Java EE 5) that declares common elements. All top-level elements are optional, and can be in any order.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</context-param>

<session-config> <!-- 10 minutes -->
<session-timeout>10</session-timeout>
</session-config>

<servlet>
<display-name>Servlet1</display-name>
<servlet-name>Servlet1</servlet-name>
<servlet-class>test.Servlet1</servlet-class>
<init-param>
<param-name>sleep-time-in-seconds</param-name>
<param-value>10</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

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

<env-entry>
<description>admin email</description>
<env-entry-name>adminEmail</env-entry-name>
<env-entry-value>admin@example.x</env-entry-value>
</env-entry>

<resource-ref>
<res-ref-name>HRDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<mapped-name>jdbc/__default</mapped-name>
</resource-ref>

<filter>
<display-name>Filter1</display-name>
<filter-name>Filter1</filter-name>
<filter-class>Filter1</filter-class>
</filter>

<filter-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Filter1</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Filter1</filter-name>
<servlet-name>Servlet1</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>

<listener>
<listener-class>Listener1</listener-class>
</listener>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

</web-app>

5 comments:

tea said...

Servlets belong in WEB-INF/classes. On this machine, the source is in Java source in /var/www/hosts/www.caucho.com/webapps/resin-3.0/WEB-INF/classes. WEB-INF/classes is the standard location for servlets and other Java classes. Resin automatically reloads and recompiles servlets, beans, and classes placed in WEB-INF/classes. You should make some changes and add errors to become familiar with Resin's recompilation and the error reporting.

Mediocre-Ninja.blogSpot.com said...

any order? The filters and listeners should be listed before servlets :-) .

Narain ashwin said...

This works like magic for weblogic 10.3 .Thanks a lot mate...

Term Papers said...

I have been visiting various blogs for my term papers writing research. I have found your blog to be quite useful. Keep updating your blog with valuable information... Regards

lee woo said...

It's just better to be yourself than to try to be some version of what you think the other person wants. See the link below for more info.


#version
www.ufgop.org