0% found this document useful (0 votes)
157 views72 pages

Struts

The document provides information about a course on the Jakarta Struts framework. It outlines the course objectives, session plan, and required software. It then covers fundamentals of web computing using servlets and JSPs. It introduces the MVC design pattern used in Struts and describes the framework's controller, model, and view components. Key controller classes in Struts like ActionServlet and RequestProcessor are also summarized.

Uploaded by

dibsruc
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views72 pages

Struts

The document provides information about a course on the Jakarta Struts framework. It outlines the course objectives, session plan, and required software. It then covers fundamentals of web computing using servlets and JSPs. It introduces the MVC design pattern used in Struts and describes the framework's controller, model, and view components. Key controller classes in Struts like ActionServlet and RequestProcessor are also summarized.

Uploaded by

dibsruc
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 72

Jakarta Struts

Course Objectives
At the end of the course you will be able to
• Understand what is Struts and its benefits as an application framework
• Understand the Model-View-Controller design pattern
• Understand the concepts of Struts Framework and its components
Session Plan

Fundamentals of Web computing (Servlet & JSP)


JSP Model
OO Application Frameworks
Introduction to Struts Framework
STRUTS MVC Design Pattern
Controller Components
Model Components
View Components
Tag Libraries
STRUTS Configuration File
Web Application Descriptor File
Application Resources File
Resources
H/W & S/W Required
Tomcat Server
Struts API jar files
Fundamentals of Web computing
(Servlet & JSP)
Fundamentals of Web computing (Servlet & JSP) (Cont.)
Java Web Development Functional Application Tiers
Fundamentals of Web computing (Servlet & JSP) (Cont.)
Java Servlets
• Execute quickly
• Portable
• Integrate well with Java back-end
• Use familiar CGI style and Java API
• Difficult to maintain
Fundamentals of Web computing (Servlet & JSP) (Cont.)
Servlet serving a client request
Fundamentals of Web computing (Servlet & JSP) (Cont.)
Servlet Sample Code
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SimpleServlet extends HttpServlet {

public void doGet (HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException
{
PrintWriter out;
String strTitle = "Simple Servlet Output";

// set content type and other response header fields first


response.setContentType("text/html");

// then write the data of the response


out = response.getWriter();
out.println ("<HTML><HEAD><TITLE>");
out.println (strTitle);
out.println ("</TITLE></HEAD><BODY>");
out.println ("<P>This is the output from SimpleServlet.");
out.println ("</BODY></HTML>");
out.close ();
}
}
Fundamentals of Web computing (Servlet & JSP) (Cont.)
Java Server Pages

JSP file

Pre-processed Generated
Servlet

Compiled Servlet
.class file
Fundamentals of Web computing (Servlet & JSP) (Cont.)
JSP page is translated and compiled into a Java Servlet
Fundamentals of Web computing (Servlet & JSP) (Cont.)
JSP Sample Code
<%@ page info="Books" errorPage="error.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Book Page</title></head><body>
<h1>Book Form</h1>
<jsp:useBean id="bookBean" class="BookForm" scope="request"/>
<table>
<tr><td>Title:</td>
<td><input name="title" type="text" value='<jsp:getProperty name="bookBean" property="title"/>'</td></tr>
<tr><td>Author:</td>
<td><input name="author" type="text" value='<jsp:getProperty name="bookBean" property="author"/>'></td></tr>
<tr><td>Publisher:</td>
<td><input name="publisher" type="text" value='<jsp:getProperty name="bookBean" property="publisher"/>'></td></tr>
<tr><td>Year:</td>
<td><input name="year" type="text" value='<jsp:getProperty name="bookBean" property="year"/>'></td></tr>
<tr><td>URL:</td>
<td><input name="url" type="text" value='<jsp:getProperty name="bookBean" property="url"/>'></td>
</table>
<A HREF="/clearBook.jsp">Clear form</A><BR>

JSP Model
JSP Model (Cont.)
JSP Model 1 Architecture
• JSP page processes request and returns response to client
• Separates content from presentation using JavaBeans
• Forms are submitted to the pages that created them
JSP Model (Cont.)
JSP Model 1 Architecture
JSP Model (Cont.)
Problems with JSP Model 1 Architecture
• Uses much scriplet code in JSP
• Pages can be large and complicated
• Still embeds navigation in page
• Boundaries of responsibility are still unclear.
• Can lead to spaghetti code
• Tends not to be modular
JSP Model (Cont.)
JSP Model 2 Architecture
JSP Model (Cont.)
JSP Model 2 Architecture
• A clear separation of the business logic, presentation output, and request processing.
• Clearly delineates responsibility
• Change layout without changing code
• This separation is often referred to as a Model-View-Controller (MVC)
JSP Model (Cont.)
MVC Design Pattern
The MVC pattern has three key components:
• The Model Component
 Responsible for the business domain state knowledge
• The View Component
 Responsible for a presentation view of the business domain
• The Controller Component
 Responsible for controlling flow and state of the user input
OO Application Frameworks
OO Application Frameworks
What are OO Application Frameworks?
 A framework is made up of multiple classes or components, each of which may
provide an abstraction of some particular concept
 The framework defines how these abstractions work together to solve a problem
 The framework components are reusable
 Frameworks are tested, proven software designs and implementations that reduce
the cost, accelerate development speed and improve the quality of software
 A good framework should provide generic behavior that can be utilized across
many different types of applications.
OO Application Frameworks (Cont.)
Benefits of using OO Application Frameworks
• Provide developers with modular, reusable and extensible software components
• Modular frameworks reduce the time and effort and investment required to
understand and maintain existing software
• Fosters reuse. Contributes improvements in programmer productivity, as well as
enhancing the quality, performance, reliability and interoperability of software
• Extensibility is essential to ensure timely customization of new application services
and features
• Reduces the cost of building and maintaining software
OO Application Frameworks (Cont.)
Business benefits of using OO Frameworks & Tools
• Adherence to standards
• Uniformity of Code
• Accelerates Software Development
• Reduces cost of development and maintenance
• Reduces developer intervention
Introduction to Struts Framework
Introduction to Struts Framework
What is the Struts Framework?
• Struts is an open source framework created within the Jakarta project by the Apache
Software Foundation
• Struts is a JSP/Servlet framework for building J2EE applications
• Struts accelerates application development based on the Model-View-Controller
(MVC) design pattern
• Current version 1.1
• For more info on struts go to:
http://jakarta.apache.org/struts/
Introduction to Struts Framework (Cont.)
Where does Struts Fit In?
Introduction to Struts Framework (Cont.)
Struts Strengths
• Integrates well with J2EE
• Open Source
• Good taglib support
• Works with existing web apps
• Easy to retain form state
• Unified error handling (via ActionError)
• Easily construct processes spanning multiple steps
• Clear delineation of responsibility makes long term maintenance easier (more
modular)
STRUTS MVC Design Pattern
STRUTS MVC Design Pattern (Cont.)

3 Major Components in STRUTS


• Application Business Logic (Model)
 Model encapsulates business logic
• Servlet controller (Controller)
 Intercept requests from the clients
 Collect results from the business operation and make them available to the client
 Translate and map each request to a business operation.
 Determine the view to display to the client based on the current state and result of the business
operation.
• Java Server Pages (View)
 JSP page for generating GUI
 Control forwarded back through the Controller to the appropriate View
STRUTS MVC Design Pattern (Cont.)

The Struts framework


STRUTS MVC Design Pattern (Cont.)

The Struts Component Packages


• Struts framework consists of 7 top-level packages
Controller Components
STRUTS Controller Components

Several different components have controller responsibilities in


the Struts framework
STRUTS Controller Components

The ActionServlet Class


• The org.apache.struts.action.ActionServlet acts as the primary controller for the Struts
framework.
• All requests from the client tier must pass through this component before proceeding
anywhere else in the application.
• Just like any other servlet, it extents javax.servlet.http.HttpServlet and implements
init(), doGet(), doPost() and destroy() methods.
• Both doGet() and doPost() methods invoke process() method to handle the client
request.
STRUTS Controller Components

The ActionServlet Class (cont.)


• process() method invokes RequestProcessor.process() method to retrieve <action>
element by reading from the struts-config.xml file. The mapping between the request
and struts-config.xml file is obtained by matching the path passed in the <html:form />
tag’s action element.
 Example:
 JSP :- <html:form action=“/Lookup” name=“lookupform”>
 struts-config.xml :- <action path=“/Lookup” name=“lookupform”>... </action>
• When RequestProcessor.process() has the matching <action>, it looks for <form-
bean> entry in struts-config.xml file that has the same name matching. It retrieves the
form bean object and populates the bean with the values obtained from the request.
 Example of Struts-config.xml:-
<form-bean>
<form-bean name=“lookupform” type=“com.caritor.sample.lookupForm”>
</form-bean>
STRUTS Controller Components

The ActionServlet Class (cont.)


• RequestProcessor.process() invokes ActionForm.validate() method, which checks the
validity of the submitted values.
• Once validation is happened successfully RequestProcessor.process() invokes
Action.execute() method to process the application business logic.
• After processing the business logic, Action class will return the ActionForword object
that is used to determine the target of this transaction. Then the request is forwarded
to the determined target.
• At this point the ActionServlet instance has completed its processing for this request
and is ready to service future requests.
STRUTS Controller Components

Extending default ActionServlet


• Prior to version 1.1, the ActionServlet contained much of the code to process each
user request. Starting with 1.1 however, most of that functionality has been moved to
org.apache.struts.action.RequestProcessor class. This new class has been added to
help relieve the ActionServlet from most of the controller burden.
• Although the framework still allows you to extend the ActionServlet, the benefit is not
as great as with earlier versions, since most of the functionality lies in the new
RequestProcessor class. If you would still like to use your own version, you just need
to create a class that extends ActionServlet and configure the framework to use this
class instead of the one from Struts.
STRUTS Controller Components

The Initialization Parameters of the ActionServlet


Parameter Description

Names the context-relative path to the struts-config.xml file. The default location is in the /WEB-INF/struts-
config
config.xml directory. (Optional)

Names the context-relative path to the struts-config.xml file associated with a particular Struts Module.
config/${module}
(Optional)

A boolean parameter used to simulate Struts 1.0x functionality when populating an ActionForm. When this
convertNull parameter is set to true, numeric objects (java.lang.Integer, etc.) are initialized to null. If it is set to false,
these objects are set to 0.
Determines the debugging level for the ActionServlet. The default value is 0, which turns debugging off.
debug
(Optional)

Sets the debug level for the Digester object, which is used during ActionServlet initialization. The default
detail
value is 0. (Optional)

Names the fully qualified class of the MultipartRequestHandler implementation to be used when file
multipartClass uploads are being processed. The default value is
org.apache.struts.upload.DiskMultipartRequestHandler. (Optional)

If set to true, tells the ActionServlet that we want to validate the strut-config.xml file against its DTD. While
validating
this parameter is optional, it is highly recommended and therefore the default is set to true.
STRUTS Controller Components

Configuring the ActionServlet


• Example configuration for default ActionServlet in web.xml :-
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<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>
<load-on-startup>1</load-on-startup>
</servlet>
STRUTS Controller Components

Configuring the ActionServlet (cont.)


• Example configuring the framework to use your ActionServlet in web.xml :-
<servlet>
<servlet-name>ExtendedActionServlet</servlet-name>
<servlet-class>com.caritor.servlet.ExtendedActionServlet</servlet-class>
<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>
<load-on-startup>1</load-on-startup>
</servlet>
STRUTS Controller Components

Your primary responsibilities are:


• Write an Action class (that is, an extension of the Action class) for each logical
request that may be received
• Write the action mapping configuration file (in XML) that is used to configure the
controller servlet (struts-config.xml)
• Update the web application deployment descriptor file (in XML) for your application to
include the necessary Struts components
• Add the appropriate Struts components to your application
STRUTS Controller Components

The Action Class


• The org.apache.struts.action.Action class is at the heart of the framework.
• Its purpose is to act as a bridge between the client request and the business
operation
• Each Action class is typically designed to perform a single task or business
operation on behalf of a client.
• The Action class defines a execute method that you must override.
• The goal of an Action class is to process this request, and then to return an
ActionForward object that identifies the JSP page (if any) to which control should
be forwarded to generate the corresponding response
STRUTS Controller Components

The Struts Framework defines two execute() methods.


The first execute()
• This Implementation is used when you are defining custom Actions that are not HTTP
specific.
• This implementation of the execute() method is analogous to the
javax.serlvet.GenericServlet class; its signature is:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
ServletRequest request,
ServletResponse response)
throws IOException, ServletException
STRUTS Controller Components

The Struts Framework defines two execute() methods. (cont.)


The second execute()
• This Implementation is used when you are defining HTTP-specific custom Actions. This
implementation of the method is analogous to the javax.servlet.http.HttpServlet class; its signature is:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
• Notice that this method (unlike the first one) receives, as its third and fourth parameter, an
HttpServletRequest and an HttpServletResponse object. This implementation of the execute() method
is the one that you will most often extend.
STRUTS Controller Components

Steps to create your own Action class


• Create a class that extends the org.apache.struts.action.Action class.
• Implement the appropriate execute() method and add your specific business logic.
• Compile the new Action and move it into the Web application's classpath. This would
most often be your WEB-INF/classes directory.
• Add an <action> element to the application's struts-config.xml file describing the new
Action.
STRUTS Controller Components

Attributes of an <action> Element


Attribute Description
Names a request or session scope attribute that is used to access an Action-Form bean, if it is other than the bean's specified
attribute
"name".
Names the fully qualified class name of the ActionMapping implementation class you want to use in when invoking this Action
className class. If the className attribute is not included, the ActionMapping defined in the ActionServlet's mapping initialization
parameter is used. We use the attribute when we create a new ActionMappings implementation.
Represents a Module-relative path of the servlet or JSP resource that will process this request. This attribute is used if you do
forward not want an Action to service the request to this path. The forward attribute is valid only if no include or type attribute is
specified.
Represents a Module-relative path of the servlet or JSP resource that will process this request. This attribute is used if you do
include not want an Action to service the request to this path. The include attribute is valid only if no forward or type attribute is
specified.
Represents a Module-relative path of the input form to which control should be returned if a validation error is encountered. The
input
input attribute is where control will be returned if ActionErrors are returned from the ActionForm or Action objects. (Optional)
name Identifies the name of the form bean that is coupled with the Action being defined.
path Represents the Module-relative path of the submitted request. The path must be unique and start with a / character.
parameter A generic configuration parameter that is used to pass extra information to the Action object defined by this action mapping.
roles A comma-delimited list of security roles that can access the defined <action /> object.
Names the fully qualified class name of the Action class being described by this ActionMapping. The type attribute is valid only
type
if no include or forward attribute is specified.
Names the scope of the form bean that is bound to the described Action. The possible values are request or session. The
scope
default value is session.
If set to true, this <action /> is used as the default action mapping when a request does not match another <action /> element.
unknown
Only one ActionMapping can be marked as unknown per Module.
If set to true, causes the ActionForm.validate() method to be called on the form bean associated to the Action being described.
validate
If the validate attribute is set to false, then the ActionForm.validate() method is not called. The default value is true.
STRUTS Controller Components

A sample <action> sub-element


<action-mappings>
<action path="/Lookup” type=“com.caritor.action.LookupAction"
name="lookupForm” input="/index.jsp">
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
</action-mappings>
• The Action class is implemented by the com.caritor.action.LookupAction class.
 This Action should be invoked when the URL ends with the path /Lookup.
 This Action class will use the <form-bean> with the name lookupForm.
 The originating resource that submitted the request to this Action is the JSP index.jsp.
 This Action class will forward the results of its processing to either quote.jsp or index.jsp depending on the
returned ActionForward
STRUTS Controller Components

The ActionForward class


• Struts provides the forward as an alternative to hard-coding URLs inside your
application
• Forwards allow you to define logical names for URLs and then to use the names to
reference the URLs
• If you reference a URL by its logical name instead of referencing it directly, when the
URL changes, you don’t have to update each reference to the URL
• Forwards are defined declaratively in the Struts configuration file. There are two types
of forwards that can be defined, a global forward and an action-specific forward
• Global forwards are available throughout an application, whereas action-specific
forwards are available only to their respective action.
STRUTS Controller Components

Following is an example of how to define a global forward in the Struts configuration


file:
<global-forwards>
<forward name="searchPage" path="/search.jsp"/>
</global-forwards>
Action-specific forwards are defined by nesting the forward tag inside an action tag,
as shown next:
<action-mappings>
<action path="/updateUser"
type="com.jamesholmes.example.UpdateUserAction">
<forward name="success" path="/updateSuccess.jsp"/>
</action>
</action-mappings>
STRUTS Controller Components

A typical Action class implementation of its execute() method


• Validate the current state of the user's session
• If validation has not yet occurred, validate the form bean properties as necessary
• Perform the processing required to deal with this request
• Update the server-side objects that will be used to create the next page of the user
interface
• Return an appropriate ActionForward object that identifies the JSP page to be used
to generate this response, based on the newly updated beans
STRUTS Controller Components

Design issues to remember when coding Action classes


• The controller Servlet creates only one instance of your Action class, and uses it for
all requests. Thus, you need to code your Action class so that it operates correctly in
a multi-threaded environment, just as you must code a Servlet's service() method
safely
• The most important principle that aids in thread-safe coding is to use only local
variables, not instance variables, in your Action class
• The beans that represent the Model of your system may throw exceptions due to
problems accessing databases or other resources. You should trap all such
exceptions in the logic of your execute() method, and log them to the application
logfile
• As a general rule, allocating scarce resources and keeping them across requests
from the same user (in the user's session) can cause scalability problems
Model Components
STRUTS Model Components

Model layer breakdown


STRUTS Model Components

Model layer breakdown (Cont.)


• External interface Composed of code that provides an interface that external code
uses to interact with the Model.
• Business logic Encompasses the bulk of the Model code and provides the business
functionality for an application.
• Data access Composed of code for communicating with an application’s data sources
such as a database
STRUTS Model Components

Struts and the Model


• The Struts framework does not provide any specific features or constraints for developing the Model
layer of your application
• At first glance this may seem odd, or even a shortcoming, given that Struts is designed for building
MVC applications. However, it's actually a key design feature of Struts and is a great benefit.
• By not dictating how the Model layer should be built, Struts gives your application the flexibility to use
any approach or technology for building the Model layer code
• Whether it be Enterprise JavaBeans (EJB), Java Data Objects (JDO), or the Data Access Objects
(DAO) pattern, Struts will accommodate
• Because the Model defines the business logic, the Model is where Struts ends and your application
code begins
• You should not place any business logic or data access code in Action objects. Doing so would bypass
the separation of the Model and the Controller
View Components
STRUTS View Components

The View Layer


• The View layer provides an interface to your application, be it for users with a
browser or for another application using something like Web services.
• Basically the View layer is the conduit for getting data in and out of the
application.
• It does not contain business logic, such as calculating interest for a banking
application or storing items in a shopping cart for an online catalog.
• The View layer also does not contain any code for persisting data to or
retrieving data from a data source. Rather, it is the Model layer that manages
business logic and data access.
• The View layer simply concentrates on the interface.
STRUTS View Components

Struts’ HTML/JSP View layer support can be broken down into the following
major components:
 JSP pages
 Form Beans
 JSP tag libraries
 Resource bundles
Tag Libraries
STRUTS Tag Libraries

List of Tag Libraries


• HTML Tags
• Bean Tags
• Logic Tags
• Template Tags
• Custom Tags
STRUTS Configuration File
STRUTS Configuration File

The Struts Configuration File


• Upon application startup, Struts loads its configuration file(s) and creates a series of
configuration objects that correspond to the settings in the file. Struts then uses those
configuration objects to guide its behavior.
• The Struts configuration file is XML-based and its format is governed by a Document
Type Definition (DTD) file that specifies how the configuration tags must be ordered in the
file, what settings are required, and so on.
• Each Struts configuration file declares its conformance to the DTD by having the following
DOCTYPE definition at the top of the file:
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
• When Struts reads the configuration file, its XML parser uses the DOCTYPE definition to
determine the DTD that the XML file must conform to.
• If configured to do so, the XML parser will validate the XML file’s conformance to the
DTD.
STRUTS Configuration File

Struts Configuration File Tags


Tag Description
Maps an application URL either to an Action object that will be executed when
action
the specified URL is requested or to another URL that will be forwarded to.
action-mappings Encapsulates the set of actions the application will have.
controller Defines several global configuration settings for a Struts application.
Defines a Java data source that an application can use to access a database or
data-source
similar resource.
data-sources Encapsulates the set of data sources the application will have.
exception Defines an exception handler to process a specific exception thrown by an Action.
form-bean Defines a Form Bean and assigns a logical name to it.
form-beans Encapsulates the set of Form Beans the application will have.
form-property Defines a form property for dynamic Form Beans.
Defines a logical name for a URL, thus allowing code to reference the logical
forward
name and not the URL itself.
Encapsulates a set of exception handlers, defined by exception tags, which are
global-exceptions
global to the application.
Encapsulates a set of forwards, defined by forward tags, which are global to the
global-forwards
application.
Defines a resource bundle that Struts will use when looking up externalized
message-resources
strings, messages, and labels.
Defines a plugin that Struts loads at application startup and unloads at application
plug-in
shutdown.
set-property Defines a property and its value.
Is the root tag for the Struts configuration file and thus encapsulates all other tags
struts-config
in the file.
STRUTS Configuration File

Struts Configuration File Tags


• Inside of the <struts-config> element, there are two important elements that are used
to describe your actions:
• <form-beans>
This section contains your form bean definitions. You use a <form-bean> element for
each form bean, which has the following important attributes:
 name: A unique identifier for this bean, which will be used to reference it in
corresponding action mappings. Usually, this is also the name of the request or
session attribute under which this form bean will be stored.
 type: The fully-qualified Java classname of your form bean.
• <action-mappings>
This section contains your action definitions. You use an <action> element for each of
your actions you would like to define. Each action element requires the following
attributes to be defined:
 path: The application context-relative path to the action
 type: The fully qualified java classname of your Action class
 name: The name of your <form-bean> element to use with this action
Web Application Descriptor File
Web Application Descriptor File
Web.xml File
• The final step in setting up the application is to configure the application deployment
descriptor (stored in file WEB-INF/web.xml) to include all the Struts components
that are required.
• Web.xml is a standard Web Archive deployment descriptor used to configure the
application.
Web Application Descriptor File
Configure Struts configuration files inside in the web.xml
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

</web-app>
Application Resources File
Application Resources File
The ApplicationResources.properties file
• The ApplicationResources.properties file, shown next, is based on Java’s Resource Bundle
functionality for externalizing and internationalizing application strings, messages, and labels.
# Label Resources
label.search.name=Name
label.search.ssNum=Social Security Number

# Error Resources
error.search.criteria.missing=<li>Search Criteria Missing</li>
error.search.ssNum.invalid=<li>Invalid Social Security Number</li>
errors.header=<font color="red"><b>Validation Error(s)</b></font><ul>
errors.footer=</ul><hr width="100%" size="1" noshade="true">
• You’ll notice that this file is simply comprised of name-value pairs, where the name is a key and
the value is a message corresponding to the key. Each of the name-value pairs is then used by
your Struts application whenever a string, message, or label needs to be displayed.
• Externalizing these strings in a separate file instead of embedding them in your application
allows the strings to be changed without having to recompile the application (separation of
concerns). Externalizing the strings also allows your application to support internationalization
so that it can be tailored to different locales.
Resources
STRUTS Resources

Main Struts Web Site


• http://jakarta.apache.org/struts/index.html
Struts User Guide
• http://jakarta.apache.org/struts/userGuide/index.html
Various Struts Resources
• http://struts.apache.org/resources/index.html
Struts Workflow Extension
• http://www.livinglogic.de/Struts/
STRUTS

Thank You

You might also like