Editing web.xml in a Struts Application

By: Gokul Verma Emailed: 1746 times Printed: 2435 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The web.xml file is where servlets and other stuff are defined to the servlet container. We'll remove some unnecessary things from the web.xml file so it looks like this:

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

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

<web-app>

  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>
	  org.apache.struts.action.ActionServlet
	</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>ApplicationResources</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

 
  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>

 
  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

</web-app>

The web.xml file -

The file contains three sections:

  1. the definition of the Struts servlet named "ActionServlet"
  2. the URL mapping for the calls to this servlet
  3. the definitions of the Struts tag libraries

You'll see that the servlet will be called if our browser requests a file called <some-name>.do. So when we submit the form in our one-page application we'll decide to use the action-name "submit.do". How the Struts servlet knows what to do with this request we'll discover next.


Struts Home | All Struts Tutorials | Latest Struts Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(4)


1. View Comment

yes simple good it wroking goog

View Tutorial          By: durga prasad pavirala at 2009-02-11 03:43:04
2. View Comment

good

View Tutorial          By: rajesh sharma at 2011-07-18 05:20:56
3. View Comment

what is the usage of 'detail' and 'debug' init parameters in web.xml.

View Tutorial          By: uday at 2011-07-21 04:53:02
4. View Comment

need to be place taglig in the <jsp-config> tag without this will be a error

View Tutorial          By: Shaik Basha at 2013-01-30 03:11:41

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Gokul Verma
Creating the first application using Struts 2
Editing struts-config.xml in a Struts Application
Editing web.xml in a Struts Application
The directories and files of a Struts application
Downloading and installing Struts

More Tutorials in Struts
Configuring JDBC DataSources in Struts
Struts Classes
FAQ: Why was reload removed from Struts (since 1.1)?
FAQ: Why are my checkboxes not being set from ON to OFF?
Using JavaScript to submit a form in Struts
How to prepopulate a form in Struts
Simple example of using the requiredif Validator rule in Struts
Chaining actions in Struts
When is the best time to validate input in Struts
What is a Plug-in and how to use Java plug-ins with Struts?
7 Best Practices of Struts
Origin and Architecture of Struts
ActionErrors and ActionError in Struts
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
Handling multiple buttons in HTML Form in Struts

More Latest News
Most Viewed Articles (in Struts )
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
MVC Architecture (Model 2 Architecture)
Struts 1 vs Struts 2
Handling Duplicate Form Submissions in Struts
Introduction to Struts Architecture
ForwardAction in Struts
IncludeAction in Struts
Simple example of using the requiredif Validator rule in Struts
The directories and files of a Struts application
Editing web.xml in a Struts Application
Model 1 Architecture
Protecting JSPs from direct access in Struts
What is Struts? Which Version of Struts to use?
Configuring JDBC DataSources in Struts
Editing struts-config.xml in a Struts Application
Most Emailed Articles (in Struts)
Guidelines for Struts Application Development
What is a Model View Controller (MVC) Model?
WebWork 2 is now Apache Struts 2
Downloading and installing Struts
Struts 1 vs Struts 2
Using Multibox in Struts
Simple example of using the requiredif Validator rule in Struts
Is Struts the most popular web application framework for Java?
The directories and files of a Struts application
ActionErrors and ActionError in Struts
ForwardAction in Struts
Chaining actions in Struts
History of Struts
Editing web.xml in a Struts Application
Creating Struts Modules