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>

12 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

Silvia Jacinto said...

Reading your article is such a privilege. It does inspire me, I hope that you can share more positive thoughts. Visit my site too. The link is posted below.

n8fan.net

www.n8fan.net

Steve Smith said...

Great and Useful Article.

Online Java Course

Java Online Training

Java Course Online

J2EE training

online J2EE training

Best Recommended books for Spring framework

Java Interview Questions












Java Training Institutes in Chennai

Java Training in Chennai

J2EE Training in Chennai

java j2ee training institutes in chennai

Steve Smith said...

Great and Useful Article.

Online Java Course

Java Online Training

Java Course Online

J2EE training

online J2EE training

Best Recommended books for Spring framework

Java Interview Questions












Java Training Institutes in Chennai

Java Training in Chennai

J2EE Training in Chennai

java j2ee training institutes in chennai

SAP ABAP Training Course Course said...

java j2ee online training classes

Paul Smith said...

I'm glad to see the detailed description of this sample web.xml based on Servlet 2.5 (part of Java EE 5) that declares common elements. I feel more comfortable with Java now! Well, guys, I need to write a custom paper, so it's time to leave!

Modern Pathshala said...

Read why load-on-startup used in web.xml at http://modernpathshala.com/Article/2043/why-load-on-startup-is-used-in-web-xml

sarah lee said...

I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


edupdf.org

pokemon go on windows said...

Now you can download pokemon go on your windows device as Microsoft has played a brilliant role in developing windows supported pokemon go.