Nicozan-Blog

Knowledge Seeking

Basic Elements Of The web.xml File September 14, 2010

Filed under: Java — nicozan @ 2:44 pm

As you might know every Java WebApplication has a web.xml file inside the WEB-INF folder. In this post we’ll try to explain the basic elements of this file. Let us see the next snippet of a web.xml file:

<servlet>
<servlet-name>WebApp</servlet-name>
<servlet-class>org.nicozan.WebApp</servlet-class>
</servlet>

<servlet-mapping>

<servlet-name>WebApp</servlet-name>
<url-pattern>/webApp</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>pagJsp.jsp</welcome-file>
</welcome-file-list>

Tags Explanation:

  • <servlet></servlet>: It`s implemented to define a servlet we are going to use in our WebApp.
  • <servlet-name></servlet-name>: An attribute of the <servlet> element, define to Identify our servlet in the web.xml file.
  • <servlet-class></servlet-class>: An attribute of the <servlet> element, define to set the Class where the servlet is implemented. (Full Class Name package.Class).
  • <servlet-mapping></servlet-mapping>: It`s implemented to map our servlet to an specific URL.
  • <servlet-name></servlet-name>: An attribute of the <servlet-mapping> element, it references a servlet that is going to be mapped.
  • <url-pattern></url-pattern>: An attribute of the <servlet-mapping> element, that specifies the url pattern where the servlet is being mapped.
  • <welcome-file></welcome-file>: With this tag you will be able to set your main web page in your WebApplication.
Advertisements
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s