struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [11/13] struts-site git commit: Migrates Getting started guide from Confluence to MD
Date Fri, 31 Mar 2017 05:48:13 GMT
http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/form-validation-using-xml.md
----------------------------------------------------------------------
diff --git a/source/getting-started/form-validation-using-xml.md b/source/getting-started/form-validation-using-xml.md
new file mode 100644
index 0000000..7e9a8a1
--- /dev/null
+++ b/source/getting-started/form-validation-using-xml.md
@@ -0,0 +1,146 @@
+---
+layout: default
+title: Form validation using XML
+---
+## Form Validation Using XML
+
+The example code for this tutorial, form_xml_validation, is available for checkout at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples)
+
+> 
+
+#####Introduction#####
+
+In this tutorial we'll cover how to validate a user's input in form fields using Struts 2's XML validation methodology. In the _Form Validation_  tutorial we discussed validating a user's input using the validate method in the Action class. Using a separate XML validation file gives you the ability to use validators built-in to the Struts 2 framework.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+#####Example Application#####
+
+The example application that supports this tutorial shows how to use Struts 2's XML validation methodology. The information that can be edited is encapsulated in an object of class Person.
+
+To enable the user to edit his information that is stored in the Person object, we have this form:
+
+![form-validation-1.png](attachments/att20873263_form-validation-1.png)
+
+When the user submits the form, we want to validate his entries into the form fields.
+
+#####Validation Using XML#####
+
+To validate a user's form field entries you can use a separate XML file that contains your validation rules. The XML file that contains the validation rules must be named as ActionClassName-validation.xml. In the example application, the XML validation file is named EditAction-validation.xml (see src/main/resources/org/apache/struts/edit/action).
+
+Struts 2 provides several different validators that you can use in the XML validation file. See _Validation_  for a list of validators you can employ.
+
+In the above form, we want to ensure the user enters a first name. To have the Struts 2 framework enforce that rule we can used the Struts 2 _requiredstring validator_ . This validator checks that the user has entered a string value in the form field.
+
+#####XML Validator Format#####
+
+In the XML validation file (for this example that is EditAction-validation.xml), is this XML:
+
+**XML Validator Required String**
+
+
+~~~~~~~
+<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+
+<validators>
+ <validator type="requiredstring">
+ 	<param name="fieldname">personBean.firstName</param>
+ 	<message>First name is required.</message>
+ </validator>
+</validators>
+
+
+~~~~~~~
+
+Within the validators node you can have 1 or more validator nodes. The type attribute specifies which validator you want the Struts 2 framework to use (see _Validation_ ). The param name="fieldname" node is used to tell the framework which form field entry to apply the rule to. See edit.jsp for the form fields and their name value (review [Struts 2 Form Tags](#PAGE_19300595) if you're not familiar with how to use Struts 2 form tags). The message node is used to tell the framework what message to display if the validation fails.
+
+
+
+| There are alternate ways to write the XML that goes in the validation XML file. See _Validation_  in the Struts 2 documentation for a full discussion.
+
+| 
+
+For example if the user doesn't enter a value in the first name form field and clicks on the Save Changes button, he will see the following.
+
+![form-validation-2.png](attachments/att20873264_form-validation-2.png)
+
+#####Validating An Email Address#####
+
+You can use the Struts 2 _email validator_  to validate the user's input in the email field. Here is the validator node that is in the EditAction-validation.xml file.
+
+**Email Validator**
+
+
+~~~~~~~
+ <validator type="requiredstring">
+ 	<param name="fieldname">personBean.email</param>
+ 	<message>Email address is required.</message>
+ </validator>
+ <validator type="email">
+ 	<param name="fieldname">personBean.email</param>
+ 	<message>Email address not valid.</message>
+ </validator>
+
+
+~~~~~~~
+
+Note that in the example, we are requiring the user to enter an email address and then validating the email address the user entered.
+
+#####Validating A User's Input Using A Regular Expression#####
+
+The Struts 2 framework provides a powerful way to validate a user's form field input by using the _regex validator_ . In the example application, we want to ensure the user enters the phone number in the format 999-999-9999. We can use a regular expression and the _regex validator_  to enforce this rule.
+
+**REGEX Validator**
+
+
+~~~~~~~
+<validator type="requiredstring">
+ 	<param name="fieldname">personBean.phoneNumber</param>
+ 	<message>Phone number is required.</message>
+ </validator>
+<validator type="regex">
+	<param name="fieldname">personBean.phoneNumber</param>
+	<param name="regex"><![CDATA[\d{3}-\d{3}-\d{4}]]></param>
+	<message>Phone number must be entered as 999-999-9999.</message>
+</validator>
+
+
+~~~~~~~
+
+The param name="expression" node is used to specify the regular expression that will be applied to the user's input. Note how the regular expression is contained within a CDATA section.
+
+#####Validating A User's Input Using An OGNL Expression#####
+
+In the example application, we want to ensure the user checks at least one of the car model check boxes. To enforce this rule we can use the _fieldexpression validator_ . Here's the XML for that validator node.
+
+**FieldExpression Validator**
+
+
+~~~~~~~
+<validator type="fieldexpression">
+	<param name="fieldname">personBean.carModels</param>
+	<param name="expression"><![CDATA[personBean.carModels.length > 0]]></param>
+	<message>You must select at least one car model.</message>
+</validator>
+
+
+~~~~~~~
+
+The param name="expression" node contains an OGNL expression that evaluates to true or false. We haven't previously discussed OGNL, which stands for Object-Graph Navigation Language (see [http://www.opensymphony.com/ognl/](http://www.opensymphony.com/ognl/) and _OGNL_ ). OGNL expressions can be evaluated by the Struts 2 framework as Java statements.
+
+In the above XML the value of the param name="expression" node, personBean.carModels.length \> 0, will be evaluated by the framework as a Java statement. The part personBean.carModels tells the framework to call the getCarModels method of class Person. That method returns an Array. Since class Array has a length attribute, the framework will get the value of the length attribute of the Array returned by the getCarModels method.
+
+If the user did not check any of the check boxes, the Array returned by the getCarModels method will have a length value of 0. Since the complete OGNL expression will only evaluate to true if the length value is greater than 0, the validation fails. The user will see this.
+
+![form-validation-3.png](attachments/att20873265_form-validation-3.png)
+
+The fieldexpression validator is useful when doing conditional validation of a user's input. If the OGNL expression doesn't evaluate to true then the user's input won't be allowed.
+
+#####Summary#####
+
+The Struts 2 framework provides easy-to-use validation methodologies. You can add a validate method to the Action class or have a separate XML file with validation rules or you can use a combination of both methodologies.

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/form-validation.md
----------------------------------------------------------------------
diff --git a/source/getting-started/form-validation.md b/source/getting-started/form-validation.md
new file mode 100644
index 0000000..0d16c4c
--- /dev/null
+++ b/source/getting-started/form-validation.md
@@ -0,0 +1,125 @@
+---
+layout: default
+title: Form Validation
+---
+## Form Validation
+
+This tutorial assumes you've completed the _Processing Forms_  tutorial and have a working form_processing project. The example code for this tutorial, form_validation, is available for checkout from the Struts 2 GitHub repository: [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples).
+
+> 
+
+__Introduction__
+
+In this tutorial we'll explore using Struts 2 to validate the user's input on a form. There are two ways you can use Struts 2 to do form validation. This tutorial will cover the more basic method, where the validation is included in the Struts 2 Action class.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+__Add validate Method__
+
+To enable the Struts 2 Action class to validate a user's input on a Struts 2 form, you must define a validate method in your Action class. Using the example from _Processing Forms_  tutorial, let's say that we have these business rules:
+
+1. User must provide a first name
+ 2. User must provide an email address
+ 3. User younger then 18 cannot register
+
+If you recall from the _Processing Forms_  tutorial the user's input into the form fields is placed by Struts 2 into the Java model class personBean. So a user's input into the firstName field would end up as the value for personBean's firstName instance field (via the personBean.setFirstName method).
+
+In the validate method we can refer to get the values of personBean's instance fields by using the appropriate get methods. Once we have the values we can employ logic to enforce our business rules.
+
+Add the following validate method to Register.java (the Action class).
+
+**validate method**
+
+
+~~~~~~~
+	public void validate(){
+		
+		if ( personBean.getFirstName().length() == 0 ){	
+
+			addFieldError( "personBean.firstName", "First name is required." );
+			
+		}
+		
+				
+		if ( personBean.getEmail().length() == 0 ){	
+
+			addFieldError( "personBean.email", "Email is required." );
+			
+		}
+		
+		if ( personBean.getAge() < 18 ){	
+
+			addFieldError( "personBean.age", "Age is required and must be 18 or older" );
+			
+		}
+		
+		
+	}
+
+~~~~~~~
+
+When the user presses the submit button on the register form, Struts 2 will transfer the user's input to the personBean's instance fields. Then Struts 2 will automatically execute the validate method. If any of the if statements are true, Struts 2 will call its addFieldError method (which our Action class inherited by extending ActionSupport).
+
+If any errors have been added then Struts 2 will not proceed to call the execute method. Rather the Struts 2 framework will return "input" as the result of calling the action.
+
+__Handle Input Being Returned__
+
+So what should we do if Struts 2 returns "input" indicating that the user's input in the form is not valid? In most cases we will want to redisplay the web page that has the form and include in the form error messages to inform the user what is wrong.
+
+To handle the return value of "input" we need to add the following result to our action node in struts.xml.
+
+
+~~~~~~~
+<result name="input">/register.jsp</result>
+
+~~~~~~~
+
+The above result node goes just after the success result node for the register action and before the closing of the action node.
+
+__Error Messages__
+
+So when validation fails and Struts 2 returns input, the Struts 2 framework will redisplay the register.jsp. Since we used Struts 2 form tags, automatically Struts 2 will add the error messages. These error messages are the ones we specified in the addFieldError method call. The addFieldError method takes two arguments. The first is the form field name to which the error applies and the second is the error message to display above that form field.
+
+So the following addFieldError method call:
+
+
+~~~~~~~
+addFieldError( "personBean.firstName", "First name is required.")
+
+~~~~~~~
+
+will cause the message "First name is required" to be displayed above the firstName field on the form.
+
+If you have made the above changes to the _Processing Forms_  tutorial or you have downloaded from [Google Code](http://code.google.com/p/struts2-examples/downloads/list)^[http://code.google.com/p/struts2-examples/downloads/list] either the Form_Validation_Struts2_Ant or Form_Validation_Struts2_Mvn projects run the application (see the README.txt in the project root folder). Click on the Please register link. On the registration form, just click the submit button and you should see:
+
+![form_errors.png](attachments/att14975003_form_errors.png)
+
+Struts 2 called the validate method, validation failed, the register.jsp was displayed with the error messages.
+
+__Styling The Error Messages__
+
+The Struts 2 s:head tag can be used to provide CSS that includes a style for the error message. Add 
+
+~~~~~~~
+<s:head />
+~~~~~~~
+ to register.jsp before the closing HTML 
+
+~~~~~~~
+</head>
+~~~~~~~
+ tag. Go through the same steps as above and you should see:
+
+![form_errors_styled.png](attachments/att14975001_form_errors_styled.png)
+
+__Summary__
+
+This tutorial covered validating a user's form input by adding a validate method to an Action class. There is another more sophisticated way to validate user input using XML. If you want to learn more about using XML for validation in Struts 2 see _Validation_ .
+
+__Up Next__
+
+In our next tutorial we'll cover how to use message resource files to separate out the text from the view page.

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/getting-started.md
----------------------------------------------------------------------
diff --git a/source/getting-started/getting-started.md b/source/getting-started/getting-started.md
new file mode 100644
index 0000000..c52d104
--- /dev/null
+++ b/source/getting-started/getting-started.md
@@ -0,0 +1,62 @@
+---
+layout: default
+title: Getting started
+---
+# Getting Started
+
+The framework documentation is written for active web developers and assumes a working knowledge 
+about how Java web applications are built. For more about the underlying nuts and bolts, see 
+the [Key Technologies Primer](/primer.html).
+
+Follow along with these tutorials to get started using Struts 2. The example code for the tutorials 
+available for checkout from the Struts 2 GitHub repository at [struts-examples](https://github.com/apache/struts-examples).
+The example projects use Maven to manage the artifact dependencies and to build the .war files.
+
+
+> The [Struts 2 user mailing list](/mail.html) is an excellent place to get help. If you are having a problem getting 
+> the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, 
+> post a question on the mailing list.
+
+## Examples
+
+[How to create a Struts 2 web application](how-to-create-a-struts2-web-application.html)
+
+[Hello World Using Struts 2](hello-world-using-struts2.html)
+
+[Using Tags](using-tags.html)
+
+[Coding Actions](coding-actions.html) 
+
+[Processing Forms](processing-forms.html) 
+
+[Form Validation](form-validation.html) 
+
+[Message Resource Files](message-resource-files.html) 
+
+[Exception Handling](exception-handling.html)
+
+[Debugging Struts](debugging-struts.html)
+
+[Form Tags](form-tags.html)
+
+[Form Validation Using XML](form-validation-using-xml.html)
+
+[Control Tags](control-tags.html)
+
+[Wildcard Method Selection](wildcard-method-selection.html)
+
+[Themes](themes.html)
+
+[Spring and Struts 2](spring.html)
+
+[Annotations](annotations.html)
+
+[Introducing Interceptors](introducing-interceptors.html)
+
+[Unit Testing](unit-testing.html)
+
+[HTTP Session](http-session.html)
+
+[Preparable Interface](preperable-interface.html)
+
+[Exclude Parameters](exclude-parameters.html)

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/hello-world-using-struts2.md
----------------------------------------------------------------------
diff --git a/source/getting-started/hello-world-using-struts2.md b/source/getting-started/hello-world-using-struts2.md
new file mode 100644
index 0000000..e2fe694
--- /dev/null
+++ b/source/getting-started/hello-world-using-struts2.md
@@ -0,0 +1,480 @@
+---
+layout: default
+title: Hello World using Struts 2
+---
+## Hello World Using Struts 2
+
+When you click on a hyperlink or submit an HTML form in a Struts 2 web application, the input is not sent to another server page, but to a Java class that you provide. These classes are called Actions. After the Action fires, a Result selects a resource to render the response. The resource is generally a server page, but it can also be a PDF file, an Excel spreadsheet, or a Java applet window.
+
+Suppose you want to create a simple "Hello World" example that displays a welcome message. After setting up an empty basic Struts 2 web application (see [How To Create A Struts 2 Web Application](#PAGE_14811860)), to create a "Hello World" example, you need to do four things:
+
+1. Create a class to store the welcome message (the model)
+
+2. Create a server page to present the message (the view)
+
+3. Create an Action class to control the interaction between the user, the model, and the view (the controller)
+
+4. Create a mapping (struts.xml) to couple the Action class and view
+
+By creating these components, we are separating the work flow into three well-known concerns: the View, the Model, and the Controller. Separating concerns makes it easier to manage applications as they become more complex.
+
+| 
+
+Let's look at an example model class, Action, server page, and mapping. If you like, fire up your Java IDE, and enter the code as we go.
+
+
+> This tutorial assumes you've completed the [How To Create A Struts 2 Web Application](#PAGE_14811860) tutorial and have a working basic Struts project. The example code for this tutorial, helloworld, is available for checkout from the 
+
+>  Struts 2 GitHub repository at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples). The example projects use Maven
+
+>  to manage the artifact dependencies and to build the .war files.
+
+> 
+
+__The Code__
+
+Let's modify either the basic_struts project to add a model class to store our message, a view that displays our message, an Action class to act as the controller, and a configuration that ties everything together.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting this application to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+__Step 1 - Create The Model Class MessageStore.java__
+
+If you're using the Basic_Struts2_Ant project to start with create the MessageStore class in the src folder and if you're using the Basic_Struts2_Mvn class create the MessageStore class in src/main/java. Be sure to note the package statement below.
+
+
+> 
+
+> 
+
+> Note that in the code shown below the JavaDoc comments are omitted. In the download example, JavaDoc comments are included.
+
+> 
+
+**MessageStore.java**
+
+
+~~~~~~~
+package org.apache.struts.helloworld.model;
+
+public class MessageStore {
+	
+	private String message;
+	
+	public MessageStore() {
+		
+		setMessage("Hello Struts User");
+	}
+
+	public String getMessage() {
+
+		return message;
+	}
+
+	public void setMessage(String message) {
+
+		this.message = message;
+	}
+
+}
+
+~~~~~~~
+
+In the model class above note the use of public set and get methods to allow access to the private message String attribute. The Struts 2 framework requires that objects you want to expose to the view (HelloWorld.jsp) follow the [JavaBean-style conventions](http://en.wikipedia.org/wiki/JavaBean\#JavaBean_conventions)^[http://en.wikipedia.org/wiki/JavaBean\#JavaBean_conventions].
+
+__Step 2 - Create The Action Class HelloWorldAction.java__
+
+We need an Action class to act as the Controller. The Action class responds to a user action (in this example that action will be clicking an HTML hyperlink and sending a specific URL to the Servlet container). One or more of the Action class's methods are executed and a String result is returned. Based on the value of the result, a specific view page (in this example that view page is HelloWorld.jsp) is rendered.
+
+Note the package and import statements below.
+
+**HelloWorldAction.java**
+
+
+~~~~~~~
+package org.apache.struts.helloworld.action;
+
+import org.apache.struts.helloworld.model.MessageStore;
+import com.opensymphony.xwork2.ActionSupport;
+
+public class HelloWorldAction extends ActionSupport {
+
+	private static final long serialVersionUID = 1L;
+
+	private MessageStore messageStore;
+	
+	public String execute() throws Exception {
+		
+		messageStore = new MessageStore() ;
+		return SUCCESS;
+	}
+
+	public MessageStore getMessageStore() {
+		return messageStore;
+	}
+
+	public void setMessageStore(MessageStore messageStore) {
+		this.messageStore = messageStore;
+	}
+
+}
+
+~~~~~~~
+
+The Struts 2 framework will create an object of the 
+
+~~~~~~~
+HelloWorldAction
+~~~~~~~
+ class and call the execute method in response to a user's action (clicking on a hyperlink that sends a specific URL to the Servlet container).
+
+In this example, the execute method creates an object of class 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ and then returns the String constant 
+
+~~~~~~~
+SUCCESS
+~~~~~~~
+.
+
+Note also the public getter and setter methods for the private 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ object. Since we want to make the 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ object available to the view page, 
+
+~~~~~~~
+HelloWorld.jsp
+~~~~~~~
+ we need to follow the [JavaBean-style](http://en.wikipedia.org/wiki/JavaBean\#JavaBean_conventions)^[http://en.wikipedia.org/wiki/JavaBean\#JavaBean_conventions] of providing get and set methods.
+
+__Step 3 - Create The View HelloWorld.jsp__
+
+We need a server page to present the message that is stored in the model class 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+. Create the below JSP in the 
+
+~~~~~~~
+WebContent
+~~~~~~~
+ folder (if using Ant) or in 
+
+~~~~~~~
+src/main/webapp
+~~~~~~~
+ (if using Maven).
+
+**HelloWorld.jsp**
+
+
+~~~~~~~
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+    <title>Hello World!</title>
+  </head>
+
+  <body>
+    <h2><s:property value="messageStore.message" /></h2>
+  </body>
+</html>
+
+~~~~~~~
+
+The taglib directive tells the Servlet container that this page will be using the Struts 2 tags and that these tags will be preceded by an 
+
+~~~~~~~
+s
+~~~~~~~
+.
+
+The 
+
+~~~~~~~
+<s:property>
+~~~~~~~
+ tag displays the value returned by calling the method 
+
+~~~~~~~
+getMessageStore
+~~~~~~~
+ of the 
+
+~~~~~~~
+HelloWorldAction
+~~~~~~~
+ controller class. That method returns a 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ object. By adding the 
+
+~~~~~~~
+.message
+~~~~~~~
+ onto the messageStore part of the value attribute we are telling the Struts 2 framework to call the 
+
+~~~~~~~
+getMessage
+~~~~~~~
+ method of that 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ object. The 
+
+~~~~~~~
+getMessage
+~~~~~~~
+ method of class 
+
+~~~~~~~
+MessageStore
+~~~~~~~
+ returns a String. It is that String that will be displayed by the 
+
+~~~~~~~
+<s:property>
+~~~~~~~
+ tag.
+
+We'll learn more about tags in the next tutorial. See the _Struts Tags_  for more information about tags.
+
+__Step 4 - Add The Struts Configuration In struts.xml__
+
+We need a mapping to tie the URL, the 
+
+~~~~~~~
+HelloWorldAction
+~~~~~~~
+ class (controller), and 
+ the 
+
+~~~~~~~
+HelloWorld.jsp
+~~~~~~~
+ (the view) together. The mapping tells the Struts 2 framework which class will respond to the user's action (the URL), which method of that class will be executed, and what view to render based on the String result that method returns.
+
+Edit the 
+
+~~~~~~~
+struts.xml
+~~~~~~~
+ file (in the Mvn project that file is in the src/main/resources folder) to add the action mapping. Place the action node (action name="hello") between the opening and closing package node, just after the action mapping with the name="index". Your complete struts.xml should look like:
+
+**struts.xml**
+
+
+~~~~~~~
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE struts PUBLIC
+    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+    "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+
+  <constant name="struts.devMode" value="true" />
+
+  <package name="basicstruts2" extends="struts-default">
+    <action name="index">
+      <result>/index.jsp</result>
+    </action>
+		
+    <action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute">
+      <result name="success">/HelloWorld.jsp</result>
+    </action>
+  </package>
+</struts>
+
+~~~~~~~
+
+__Step 5 - Create The URL Action__
+
+In index.jsp (see WebContent folder for Ant project and src/main/webapp for Mvn project) let's add an Action URL the user can click on to tell the Struts 2 framework to run the execute method of the HelloWorldAction class and render the HelloWorld.jsp view.
+
+First add the taglib directive at the top of the jsp 
+
+~~~~~~~
+<%@ taglib prefix="s" uri="/struts-tags" %>
+~~~~~~~
+. Next add this p tag 
+
+~~~~~~~
+<p><a href="<s:url action='hello'/>">Hello World</a></p>
+~~~~~~~
+ after the h1 tag. Your new index.jsp should look like:
+
+**index.jsp**
+
+
+~~~~~~~
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Basic Struts 2 Application - Welcome</title>
+</head>
+<body>
+<h1>Welcome To Struts 2!</h1>
+<p><a href="<s:url action='hello'/>">Hello World</a></p>
+</body>
+</html>
+
+
+~~~~~~~
+
+The Struts url tag creates the URL with an action of hello. The hello action was mapped to the HelloWorldAction class and its execute method. When the user clicks on the above URL it will cause the Struts 2 framework to run the execute method of the HelloWorldAction class. After that method returns the String success, the view page HelloWorld.jsp will be rendered.
+
+__Step 6 - Build the WAR File and Run The Application__
+
+Execute mvn clean package to create the war file.
+
+Copy the war file to your Servlet container. After your Servlet container successfully deploys the war file go to this URL [http://localhost:8080/helloworld/index.action](http://localhost:8080/helloworld/index.action) where you should see the following:
+
+![Struts2HelloWorld.png](attachments/att14974994_Struts2HelloWorld.png)
+
+Click on the Hello World link and you should get the HelloWorld.jsp page:
+
+![Hello.png](attachments/att14974993_Hello.png)
+
+__Getting Help__
+
+The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting this application to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+__How the Code Works__
+
+Your browser sends to the web server a request for the URL [http://localhost:8080/Hello_World_Struts2_Ant/hello.action](http://localhost:8080/Hello_World_Struts2_Ant/hello.action).
+
+1. The container receives from the web server a request for the resource 
+
+~~~~~~~
+hello.action
+~~~~~~~
+. According to the settings loaded from the _web.xml_ , the container finds that all requests are being routed to 
+
+~~~~~~~
+org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
+~~~~~~~
+, including the 
+
+~~~~~~~
+*.action
+~~~~~~~
+ requests. The StrutsPrepareAndExecuteFilter is the entry point into the framework.
+
+2. The framework looks for an action mapping named "hello", and it finds that this mapping corresponds to the class "HelloWorldAction". The framework instantiates the Action and calls the Action's 
+
+~~~~~~~
+execute
+~~~~~~~
+ method.
+
+3. The 
+
+~~~~~~~
+execute
+~~~~~~~
+ method creates the MessageStore object and returns 
+
+~~~~~~~
+SUCCESS
+~~~~~~~
+. The framework checks the action mapping to see what page to load if 
+
+~~~~~~~
+SUCCESS
+~~~~~~~
+ is returned. The framework tells the container to render as the response to the request, the resource 
+
+~~~~~~~
+HelloWorld.jsp
+~~~~~~~
+.
+
+4. As the page 
+
+~~~~~~~
+HelloWorld.jsp
+~~~~~~~
+ is being processed, the 
+
+~~~~~~~
+<s:property value="messageStore.message" />
+~~~~~~~
+ tag calls the getter 
+
+~~~~~~~
+getMessageStore
+~~~~~~~
+ of the 
+
+~~~~~~~
+HelloWorld
+~~~~~~~
+ Action and then calls the 
+
+~~~~~~~
+getMessage
+~~~~~~~
+ of the MessageStore object returned by 
+
+~~~~~~~
+getMessageStore
+~~~~~~~
+, and the tag merges into the response the value of the message attribute.
+
+5. A pure HTML response is sent back to the browser.
+
+__What to Remember__
+
+The framework uses Actions to process HTML forms and other requests. The 
+
+~~~~~~~
+Action
+~~~~~~~
+ class returns a result-name such as 
+
+~~~~~~~
+SUCCESS
+~~~~~~~
+, 
+
+~~~~~~~
+ERROR
+~~~~~~~
+, or 
+
+~~~~~~~
+INPUT
+~~~~~~~
+. Based on the mappings loaded from the 
+
+~~~~~~~
+struts.xml
+~~~~~~~
+, a given result-name may select a page (as in this example), another action, or some other web resource (image, PDF).
+
+When a server page is rendered, most often it will include dynamic data provided by the Action. To make it easy to display dynamic data, the framework provides a set of tags that can be used along with HTML markup to create a server page.

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/how-to-create-a-struts2-web-application.md
----------------------------------------------------------------------
diff --git a/source/getting-started/how-to-create-a-struts2-web-application.md b/source/getting-started/how-to-create-a-struts2-web-application.md
new file mode 100644
index 0000000..9552c4b
--- /dev/null
+++ b/source/getting-started/how-to-create-a-struts2-web-application.md
@@ -0,0 +1,226 @@
+---
+layout: default
+title: How to create a Struts 2 web application
+---
+## How To Create A Struts 2 Web Application
+
+This tutorial walks through installing the framework and creating a simple application.
+
+<div class="alert alert-block alert-error">
+
+While the Struts 2 framework is simple to use, creating non-trivial applications assumes a working knowledge 
+of many J2EE technologies, including:
+
+  <ul>
+    <li>Java</li>
+    <li>Filters, JSP, and Tag Libraries</li>
+    <li>JavaBeans</li>
+    <li>HTML and HTTP</li>
+    <li>Web Containers (such as Tomcat)</li>
+    <li>XML</li>
+  </ul> 
+
+</div>
+
+<i class="glyphicon glyphicon-info-sign alert-info" aria-hidden="true"></i> For more about supporting technologies, 
+see the [Key Technologies Primer](/primer.html). 
+
+#### Java Requirements
+
+Struts 2 requires Servlet API 2.4 or higher, JSP 2.0 or higher, and Java 7 or higher.
+
+#### Our First Application
+
+To get started using Struts 2 we will create a web application using Maven to manage the artifact dependencies.
+You can checkout all the example applications from the Struts 2 GitHub repository 
+at [struts-examples](https://github.com/apache/struts-examples).
+
+### Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application
+
+> This tutorial assumes you know how to create a Java web application that uses Maven to manage artifacts and build 
+the web application archive (war) file.
+
+__Step 1 - Create A Java Web Application__
+
+In your Java IDE create a Java web application with a project name of basic_struts that follows the standard Maven
+project folder structure. In your pom.xml include the following:
+
+**pom.xml build node**
+
+```xml
+<build>
+    <finalName>basic_struts</finalName>
+</build>
+```
+
+__Step 2 - Add index.jsp__
+
+Our next step is to add a simple `index.jsp` to this web application. Create an `index.jsp` under `src/main/webapp`
+with a title of __Basic Struts 2 Application - Welcome__ and in the body add an h1 heading of __Welcome to Struts 2!__
+
+Run `mvn clean package` to create the war file. Copy the war file into your Servlet container so that it will deploy the war file.
+
+Start up your Servlet container and in a web browser go to [http://localhost:8080/Basic_Struts2_Mvn/index.jsp](http://localhost:8080/Basic_Struts2_Mvn/index.jsp). 
+You should see the following:
+
+![Basic_Struts2_Mvn.png](attachments/att14974992_Basic_Struts2_Mvn.png)
+
+__Step 3 - Add Struts 2 Jar Files To Class Path__
+
+Now that we know we have a working Java web application, lets add the minimal required Struts 2 framework Jar files 
+to our web application's class path. In `pom.xml` add the following dependency node:
+
+**pom.xml dependency node**
+
+```xml
+<dependency>
+    <groupId>org.apache.struts</groupId>
+    <artifactId>struts2-core</artifactId>
+    <version>X.X.X.X</version>
+</dependency>
+```
+
+Of course replace the X.X.X.X with the current Struts 2 version. Maven will get the `struts2-core` jar and the other jar 
+files struts2-core requires (transitive dependencies). 
+
+<i class="glyphicon glyphicon-info-sign alert-info" aria-hidden="true"></i> Beginning with Struts version 2.2.3 
+you do not need to specify a separate dependency node for javassist.
+
+__Step 4 - Add Logging__
+
+To see what's happening under the hood, the example application for this tutorial uses log4j. You'll need to add to pom.xml a dependency node for the log4j jar file:
+
+**pom.xml log4j dependency node**
+
+```xml
+<dependency>
+    <groupId>log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>1.2.14</version>
+</dependency>
+```
+
+Setup a `log4j.xml` configuration in the `src/main/resources` folder. You can copy the one from the example application, 
+which contains the following
+
+**log4j.xml**
+
+```xml
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+    
+    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
+       <layout class="org.apache.log4j.PatternLayout"> 
+          <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/> 
+       </layout> 
+    </appender>
+ 
+    <!-- specify the logging level for loggers from other libraries -->
+    <logger name="com.opensymphony">
+    	<level value="DEBUG" />
+    </logger>
+
+    <logger name="org.apache.struts2">
+    	 <level value="DEBUG" />
+    </logger>
+  
+   <!-- for all other loggers log only info and above log messages -->
+     <root>
+        <priority value="INFO"/> 
+        <appender-ref ref="STDOUT" /> 
+     </root> 
+    
+</log4j:configuration> 
+```
+
+Note the above log4j configuration specifies the console as the log target.
+
+__Step 5 - Add Struts 2 Servlet Filter__
+
+To enable the Struts 2 framework to work with your web application you need to add a Servlet filter class and filter 
+mapping to `web.xml`. Below is the filter and filter-mapping nodes you should add to `web.xml`.
+
+**web.xml Servlet Filter**
+
+```xml
+<filter>
+    <filter-name>struts2</filter-name>
+    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
+</filter>
+
+<filter-mapping>
+    <filter-name>struts2</filter-name>
+    <url-pattern>/*</url-pattern>
+</filter-mapping>
+```
+
+For more information about configuring the deployment descriptor for Struts 2 see `web.xml`. Note the url-pattern node 
+value is `/*` meaning the Struts 2 filter will be applied to all URLs for this web application.
+
+__Step 6 - Create struts.xml__
+
+Struts 2 can use either an XML configuration file or annotations (or both) to specify the relationship between a URL, 
+a Java class, and a view page (such as `index.jsp`). For our basic Struts 2 application, we'll use a minimal xml 
+configuration. Note the file name is `struts.xml` and it should be in the `src/main/resources` folder (`struts.xml` 
+must be on the web application's root class path).
+
+**struts.xml**
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE struts PUBLIC
+    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
+    "http://struts.apache.org/dtds/struts-2.5.dtd">
+
+<struts>
+
+    <constant name="struts.devMode" value="true" />
+
+    <package name="basicstruts2" extends="struts-default">
+
+        <action name="index">
+            <result>/index.jsp</result>
+        </action>
+
+    </package>
+
+</struts>
+```
+
+This minimal Struts 2 configuration file tells the framework that if the URL ends in `index.action` to redirect 
+the browser to `index.jsp`.
+
+For more information about the struts.xml configuration file see `struts.xml`.
+
+__Step 7 - Build and Run the Application__
+
+With all of the above in place run mvn clean package to create the war file. Remove the previously created war file 
+and exploded web application folder from your Servlet container's webapps folder. Copy to your Servlet container's webapps 
+folder the new war you just created.
+
+Start up the Servlet container. View the console where you should see numerous debug messages that tell you 
+the Struts 2 framework is being included in the `Basic_Struts2_Mvn` web application.
+
+Open a web browser and go to [http://localhost:8080/Basic_Struts2_Mvn/index.action](http://localhost:8080/Basic_Struts2_Mvn/index.action) 
+(note that's `index.action` not `index.jsp` at the end of the URL). You should see the same web page as when going to 
+[http://localhost:8080/Basic_Struts2_Mvn/index.jsp](http://localhost:8080/Basic_Struts2_Mvn/index.jsp). View the log 
+messages written to the console and you should find several that discuss `index.action` and `index.jsp`:
+
+**Struts 2 Log Messages**
+
+```
+com.opensymphony.xwork2.DefaultActionProxy.debug:57 - Creating an DefaultActionProxy for namespace / and action name index
+...
+org.apache.struts2.dispatcher.ServletDispatcherResult.debug:57 - Forwarding to location /index.jsp
+```
+
+Note that the xwork2 artifact is one of the Jar files that is a transitive dependency for the struts2-core Jar file. 
+The xwork2 library is used heavily by the Struts 2 framework.
+
+__Getting Help__
+
+The [Struts 2 user mailing list](/mail.html) is an excellent place to get help.  If you are having a problem getting 
+this Basic Struts 2 application to work search the Struts 2 mailing list. If you don't find an answer to your problem, 
+post a question on the mailing list.  

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/http-session.md
----------------------------------------------------------------------
diff --git a/source/getting-started/http-session.md b/source/getting-started/http-session.md
new file mode 100644
index 0000000..fba68cf
--- /dev/null
+++ b/source/getting-started/http-session.md
@@ -0,0 +1,154 @@
+---
+layout: default
+title: Http Session
+---
+## HTTP Session
+
+The example code for this tutorial, http_session, is available at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples)
+
+> 
+
+#####Introduction#####
+
+Your Struts 2 application may need to access the HTTP session object. Struts 2 provides an interface, [SessionAware](http://struts.apache.org/2.3.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/SessionAware.html)^[http://struts.apache.org/2.3.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/SessionAware.html], that your Action class should implement to obtain a reference to the HTTP session object.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+#####SessionAware Interface#####
+
+The SessionAware interface has one method, setSession, that your Action class will need to override. In the example application (see above), the HelloWorldAction class implements the SessionAware interface and includes this code:
+
+**HelloWorldAction.java setSession Method**
+
+
+~~~~~~~
+private Map<String, Object> userSession ;
+
+public void setSession(Map<String, Object) session) {
+
+   userSession = session ;
+
+}
+
+
+~~~~~~~
+
+The Struts 2 framework has an interceptor that will inject the HTTP session object into the Action class by calling the setSession method.
+
+#####Using the HTTP Session Object In The Action Class#####
+
+The example application keeps track of how many times the user clicks on a Hello link or submits the hello form. It stores this count in the HTTP session object in the increaseHelloCount method.
+
+**HelloWorldAction.java increaseHelloCount Method**
+
+
+~~~~~~~
+private void increaseHelloCount() {
+			
+   Integer helloCount = (Integer) userSession.get(HELLO_COUNT);
+		
+   if (helloCount == null ) {
+		
+     helloCount = 1;
+			
+   } else {
+			
+     helloCount++;
+
+   }
+		
+   userSession.put(HELLO_COUNT, helloCount);
+	
+}
+
+
+
+~~~~~~~
+
+When the increaseHelloCount method is called from within the execute method, the userSession object is a reference to the HTTP session object injected by the Struts 2 framework. So any objects stored in the HTTP session can be retrieved using the userSession object and any objects stored in the userSession object will be stored in the HTTP session object.
+
+#####Accessing HTTP Session Objects In The View#####
+
+Struts 2 provides an easy way to get an object stored in the HTTP session from within the view page. In the example application is HelloWorld.jsp with this markup:
+
+**HelloWorld.jsp Get helloCount Value From HTTP Session**
+
+
+~~~~~~~
+   <p>I've said hello to you <s:property value="#session.helloCount" /> times!</p>
+
+
+~~~~~~~
+
+The s:property tag's value attribute has a value of \#session.helloCount. The "\#" before the word session tells the Struts framework to look in the session scope for a key of "helloCount" (which is the value of the String constant HELLO_COUNT referenced in method increaseHelloCount). Struts will get the object mapped to helloCount key and then call that object's toString method to determine what to display in the view page.
+
+#####Best Practices When Using SessionAware#####
+
+Using SessionAware does introduce a potential security vulnerability that you should mitigate by also following these practices in the Action class that implements the SessionAware interface.
+
+1. Do not have a public Map<String, Object) getSession method in the Action class. You only need a public void setSession method to implement the SessionAware interface.
+
+2. Also have the Action class implement the [ParameterNameAware interface](http://struts.apache.org/2.3.1.2/xwork-core/apidocs/com/opensymphony/xwork2/interceptor/ParameterNameAware.html)^[http://struts.apache.org/2.3.1.2/xwork-core/apidocs/com/opensymphony/xwork2/interceptor/ParameterNameAware.html] and override its acceptableParameterName method:
+
+**HelloWorldAction.java acceptableParameterName Method**
+
+
+~~~~~~~
+	public boolean acceptableParameterName(String parameterName) {
+		
+		boolean allowedParameterName = true ;
+		
+		if ( parameterName.contains("session")  || parameterName.contains("request") ) {
+		
+			allowedParameterName = false ;
+			
+		} 
+		
+		return allowedParameterName;
+	}
+
+
+~~~~~~~
+
+This method will be called by the Struts 2 framework for each parameter in the request scope. By returning false if the parameter name contains "session" we are telling the Struts 2 framework to ignore that parameter. This will prevent a malicious user from trying to hack the HTTP session object.
+
+Instead of having each action that implements SessionAware also implement the ParameterNameAware interface you can tell the params interceptor to exclude specific request attributes for all actions in a package. In struts.xml configure the struts-default set of interceptors as follows:
+
+**struts.xml configure params interceptor**
+
+
+~~~~~~~
+	<package name="basicstruts2" extends="struts-default">
+
+ 		<interceptors>
+	 		<interceptor-stack name="appDefault">
+	        	 <interceptor-ref name="defaultStack">
+	      			<param name="exception.logEnabled">true</param>
+	      			<param name="exception.logLevel">ERROR</param>
+	      			<param name="params.excludeParams">dojo..*,^struts..*,^session..*,^request..*,^application..*,^servlet(Request|Response)..*,parameters...*</param>
+	   			</interceptor-ref>
+	 	    </interceptor-stack>
+		</interceptors>
+		
+		<default-interceptor-ref name="appDefault" />
+
+
+~~~~~~~
+
+The above code will ensure that every action in the "basicstruts2" package that implements the SessionAware interface will exclude from processing parameters that starts with the strings provided in the params.excludeParams noded.
+
+The example project includes both methods for mitigating the SessionAware security vulnerability.
+
+
+
+| Note the same issue exists if you implement the ServletRequestAware interface, which is why the above method returns false if the parameter name contains "request".
+
+| 
+
+#####Summary#####
+
+When your Action class needs to access the HTTP session object implement the SessionAware interface and override the setSession method. Be sure to also implement the ParameterNameAware interface and override the acceptableParameterName method to mitigate a potential security vulnerability. If you have multiple actions that implement SessionAware then consider modifying the params interceptor's excludeParams value as part of your Struts 2 package setup.

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/introducing-interceptors.md
----------------------------------------------------------------------
diff --git a/source/getting-started/introducing-interceptors.md b/source/getting-started/introducing-interceptors.md
new file mode 100644
index 0000000..9fe1a6f
--- /dev/null
+++ b/source/getting-started/introducing-interceptors.md
@@ -0,0 +1,187 @@
+---
+layout: default
+title: Introducing Interceptors
+---
+## Introducing Interceptors
+
+The example code for this tutorial, interceptors, is available at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples)
+
+> 
+
+#####Introduction#####
+
+So far our tutorials have not delved into the inner workings of the Struts 2 framework. But in this tutorial we'll introduce a key set of classes the Struts 2 framework relies upon to do most of the work whenever an Action is executed. In this tutorial's example project there is a register link that is mapped in the Struts XML configuration file (struts.xml) to the execute method of class Register. Before that execute method is called much work is done behind the scenes by the Struts 2 framework. For example:
+
+1. Handling any exceptions generated
+
+2. Converting the String request parameters to the Register class's instance fields where the name values match
+
+3. Calling the validate method and/or the external XML validation
+
+After the execute method is completed more work must be done
+
+1. Handling any exceptions generated
+
+2. Converting the Register class's instance fields to String values for display in the view page
+
+3. Forwarding to the correct view page depending on the result String returned by the execute method
+
+
+The above list of tasks are not complete - several other tasks are done before and after the execution of the Action.
+
+| 
+
+The benefit of using Struts 2 is all this work happens automatically. You can focus on the logic of the controller (the Struts 2 ActionSupport class), the Service layer, the data access layer, your domain models, etc.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+#####Introducing Interceptors#####
+
+The tasks that are done by the Struts 2 framework before and after an Action is executed are done by Struts 2 interceptors. Interceptors are standard Java classes included in the Struts 2 core jar which are executed in a specific order.
+
+In our example application there is a package node in struts.xml. The package node has an attribute of extends with a value of "struts-default." The value "struts-default" identifies to the framework the specific stack of interceptors that will be executed before and after the Actions in that package.
+
+If you want to learn more about the inner workings of interceptors, what interceptors belong to the struts default stack, and what are all the interceptors included with Struts 2, visit _Understanding Interceptors_ .
+
+Sometime the Struts 2 default stack of interceptors are not exactly what you need for a particular action. You may want to use interceptors that are not part of the Struts 2 default stack. For an individual Action or for the entire package of Actions, you can specify a different stack of interceptors that the Action or package should use. Below is how you would specify that the register Action should use both the _logger_  and _timer_  interceptors in addition to the interceptors provided by the default stack.
+
+**Specify Specific Interceptors For An Action**
+
+
+~~~~~~~
+<action name="register" class="org.apache.struts.register.action.Register" method="execute">
+	<interceptor-ref name="timer" />
+	<interceptor-ref name="logger" />
+	<interceptor-ref name="defaultStack">
+		<param name="exception.logEnabled">true</param>
+		<param name="exception.logLevel">ERROR</param>
+	</interceptor-ref>
+	<result name="success">thankyou.jsp</result>
+	<result name="input">register.jsp</result>
+</action>
+
+
+~~~~~~~
+
+The logger interceptor logs the start and end of the execution of an Action. The timer interceptor logs the amount of time (in milliseconds) for execution of the Action. These two interceptors used together can provide developers useful feedback.
+
+In the code example above note the three interceptor-ref nodes. Each one has a value for the name attribute. For the register Action we are instructing the framework to use the timer, logger, and defaultStack interceptors. The defaultStack are all the interceptors normally executed for an Action.
+
+How did I know to use the value of timer for the name attribute and even that there is a timer interceptor? On the _Interceptors_  web page in the Struts 2 documentation are a list of interceptors that come with the Struts 2 framework and what the name value is for each interceptor.
+
+How did I know that the timer interceptor isn't part of the defaultStack of interceptors already? Again on the Interceptors documentation web page is a list of which interceptors belong to the defaultStack.
+
+Note the param nodes. These nodes are used to provide a value to the setLogEnabled and setLogLevel methods of the _Exception Interceptor_ . Providing the values of true and ERROR will cause the Struts 2 framework to log any exceptions not caught by the application's code and to log those exceptions at the ERROR level.
+
+#####Run The Example#####
+
+In the example application follow the README instructions to build, deploy, and run the application. View the output sent to the JVM console to see the log messages generated by the logger and timer interceptors. You should see log messages similar to the following:
+
+INFO: Starting execution stack for action //register
+ Nov 20, 2010 9:55:48 AM com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
+
+INFO: Finishing execution stack for action //register
+
+Nov 20, 2010 9:55:48 AM com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
+
+INFO: Executed action [//register\!execute](https://cwiki.apache.org/register\!execute)^[https://cwiki.apache.org/register\!execute] took 177 ms.
+
+If you wanted to have the logger and timer interceptors executed for all Actions in a package you would use the following in struts.xml:
+
+**Specify Specific Interceptors For A Package**
+
+
+~~~~~~~
+<package name="basicstruts2" extends="struts-default" > 
+
+
+       <interceptors> 
+
+         <interceptor-stack name="appDefault"> 
+
+            <interceptor-ref name="timer" /> 
+
+            <interceptor-ref name="logger" /> 
+
+            <interceptor-ref name="defaultStack" /> 
+
+         </interceptor-stack> 
+
+        </interceptors>          
+
+        <default-interceptor-ref name="appDefault" /> 
+
+       <!-- rest of package omitted --> 
+
+</package> 
+
+
+~~~~~~~
+
+In the code above we use the interceptors node to define a new stack of interceptors that includes the timer, logger, and defaultStack interceptors. We give this new interceptor stack a name of appDefault. Then we use the default-interceptor-ref node to specify that for all Actions defined inside this package node the appDefault stack of interceptors are to be used. Thus the timer and logger interceptor will be executed for each Action in this package.
+
+Note that in both examples we are still executing all the other interceptors by including the defaultStack as one of the interceptor-ref nodes. When you specify what interceptors you want to use for an Action or a package then only those interceptors are executed. So if in the example we had left out the interceptor-ref for defaultStack only the logger and timer interceptors would have executed.
+
+#####Create Your Own Interceptor#####
+
+In addition to specifying your own stack of interceptors, you can also write your own new interceptor and add it to the stack that is executed. The Struts _Writing Interceptors_  guide explains how to do this. For example, you could create your own interceptor to handle authentication and authorization.
+
+#####Summary#####
+
+Interceptors provide the Struts 2 framework with both power and flexibility. Developers may add additional interceptors (either ones provided by Struts 2 or ones they create) to the stack of interceptors executed when an Action class is called.
+
+For more information about interceptors consult the Struts 2 _Interceptor_  documentation.
+
+##Preparable Interface## {#PAGE_27839279}
+
+The example code for this tutorial, preparable_interface, is available at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples).
+
+> 
+
+#####Introduction#####
+
+Often the data used to populate a form control is dynamically generated, perhaps from a database. When the user submits the form, the Struts 2 validation interceptor attempts to validate the user's form input. If validation fails the Struts 2 framework returns the value "input" but the "input" action is not re-executed. Rather the view associated with the "input" result is rendered to the user. Usually this view is the page that displayed the original form.
+
+This work-flow can cause a problem if one or more of the form fields or some other data displayed depends on a dynamic look-up that that is accomplished in the Action class's input method. Since the Action class's input method is not re-executed when validation fails, the view page may no longer have access to the correct information to create the form or other display information.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+#####Preparable Interface#####
+
+Struts 2 provides the [Preparable interface](http://struts.apache.org/2.3.1/xwork-core/apidocs/com/opensymphony/xwork2/Preparable.html)^[http://struts.apache.org/2.3.1/xwork-core/apidocs/com/opensymphony/xwork2/Preparable.html] to overcome this problem. An Action class that implements this interface must override the prepare method. The prepare method will always be called by the Struts 2 framework's [prepare interceptor](http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html)^[http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html] whenever any method is called for the Action class and also when validation fails before the view is rendered.
+
+In the prepare method you should put any statements that must be executed no matter what other Action class method will be called and also statements that should be executed if validation fails. Usually statements in the prepare method set the value for Action class instance fields that will be used to populate form controls and get the values that will be used to set the initial form field values.
+
+In addition to automatically running the prepare method the [prepare interceptor](http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html)^[http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html] will also call a method named prepare\[ActionMethodName\]. For example, define a prepare method and a prepareInput method in the Action class that implements preparable. When the Struts 2 framework calls the input method, the prepare interceptor will call the prepareInput and the prepare methods before calling the input method.
+
+#####Example Application#####
+
+If you examine class EditAction in the example application (see above) you'll see that it implements the Preparable Interface. In the prepare method is this code:
+
+**EditAction.java prepare Method**
+
+
+~~~~~~~
+		
+   carModelsAvailable = carModelsService.getCarModels() ;
+		
+   setPersonBean( editService.getPerson() );
+
+
+~~~~~~~
+
+The above statements get the car model values used to populate the car model check boxes displayed in the form and also get the information about the Person object being edited.
+
+When you run the example application, look in the log to see when the prepare method is called in relation to the input and execute methods. Running the example application and examining the log should help you understand the impact of implementing the Preparable Interface and the prepare method.
+
+#####Summary#####
+
+When your application requires specific statements to be executed no matter which method of the Action class is called or when validation fails, you should implement the Preparable interface and override the prepare method.

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/message-resource-files.md
----------------------------------------------------------------------
diff --git a/source/getting-started/message-resource-files.md b/source/getting-started/message-resource-files.md
new file mode 100644
index 0000000..468bc65
--- /dev/null
+++ b/source/getting-started/message-resource-files.md
@@ -0,0 +1,269 @@
+---
+layout: default
+title: Message Resource Files
+---
+## Message Resource Files
+
+This tutorial assumes you've completed the _Form Validation_  tutorial and have a working form_validation project. The example code for this tutorial, message_resource, is available for checkout from the 
+
+>  Struts 2 GitHub repository at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples).
+
+> 
+
+__Introduction__
+
+In this tutorial we'll explore using Struts 2 message resource capabilities (also called resource bundles). Message resources provide a simple way to put text in a view page that is the same through out your application, to create form field labels, and to change text to a specific language based on the user's locale (i18n).
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+__Message Resource Property Files__
+
+In a Struts 2 web application you may associate a message resource property file with each Struts 2 Action class by creating a properties file with the same name as the Action class and having the .properties extension. This properties file must go in the same package as the Action class. For our tutorial example, let's say we want to place the form field labels into a separate file where we can easily change them and also provide the capability to display the labels in other languages.
+
+If you're doing this tutorial after completing _Form Validation_  then you can make these changes to that tutorial's example application.
+
+Put the text below in a file named Register.properties in the org.apache.struts.register.action package in the src/resources/java folder.
+
+**Register.properties**
+
+
+~~~~~~~
+personBean.firstName=First name
+personBean.lastName=Last name
+personBean.age=Age
+personBean.email=Email
+thankyou=Thank you for registering %{personBean.firstName}.
+
+~~~~~~~
+
+The above is just a standard Java properties file. The key is to the left of the = sign and the value for the key is to the right. When the Register action is executed these properties will be available to the view page by referencing the key name.
+
+__Struts 2 Key Attribute__
+
+The Struts 2 key attribute can be used in the _textfield_  tag to instruct the framework what value to use for the textfield's name and label attributes. Instead of providing those attributes and their values directly, you can just use the key attribute.
+
+If you open register.jsp from the _Form Validation_  tutorial you'll see this Struts 2 textfield tag:
+
+**textfield tag**
+
+
+~~~~~~~
+<s:textfield name="personBean.firstName" label="First name" />
+
+~~~~~~~
+
+Instead of specifying the name and label attributes you can just use the key attribute.
+
+**textfield tag with key attribute**
+
+
+~~~~~~~
+<s:textfield key="personBean.firstName"  />
+
+~~~~~~~
+
+The value for the key attribute instructs the Struts 2 framework to use the same value for the name attribute (personBean.firstName). For the label attribute's value the value of the key attribute is used by the Struts 2 framework to find a key in a properties file with the same value. So in our example, Struts 2 will look in Register.properties for a key with a value of personBean.firstName. The value of that key (First name) will be used as the label attribute's value.
+
+To enable the key attribute to find the properties file, the display of the view page must be the result of executing a Struts 2 Action class. Right now if you examine index.jsp from the _Form Validation_  tutorial the link to the register.jsp page is a standard URL.
+
+**link to register.jsp**
+
+
+~~~~~~~
+<p><a href="register.jsp">Please register</a> for our prize drawing.</p>
+
+~~~~~~~
+
+We need to change the above link so that it goes through the Register.java Struts 2 Action class. Replace the above with this markup.
+
+**link to Register Action class**
+
+
+~~~~~~~
+<s:url action="registerInput" var="registerInputLink" />
+<p><a href="${registerInputLink}">Please register</a> for our prize drawing.</p>
+
+~~~~~~~
+
+We use the Struts 2 url tag to create a link to action registerInput. We then use that link as the value for the href attribute of the anchor tag. We must define the registerInput action in struts.xml. Add the following to struts.xml.
+
+**registerInput action node for struts.xml**
+
+
+~~~~~~~
+<action name="registerInput" class="org.apache.struts.register.action.Register" method="input" >
+	<result name="input">/register.jsp</result>
+</action>
+
+~~~~~~~
+
+The above action node instructs the Struts 2 framework to execute class Register's input method in response to action registerInput. The input method is inherited by class Register from class ActionSupport. The default behavior of the inherited input method is to return the String input. The result node above specifies that if the returned result is "input" then render the view register.jsp.
+
+By doing the above the view page register.jsp will have access to the properties defined in Register.properties. The Struts 2 framework will make those properties defined in Register.properties available to the view page since the view page was rendered after Register.java (the Struts 2 Action class) was executed.
+
+Follow the instructions (README.txt) in the project to create the war file and copy the war file to your servlet container. Open a web browser and navigate to the home page specified in the README.txt file (index.action). You should see a link to registerInput.action when mousing over the hyperlink Please Register.
+
+![registerInput.png](attachments/att14975007_registerInput.png)
+
+When you click on the Please Register link your browser should display the register.jsp. The form field labels should be the key values from the Register.properties file.
+
+![register.png](attachments/att14975006_register.png)
+
+__Struts 2 Text Tag__
+
+We can also use the Struts 2 text tag to display values from a properties file. In thankyou.jsp add this text tag instead of the h3 tag that is in thankyou.jsp.
+
+**text tag**
+
+
+~~~~~~~
+<h3><s:text name="thankyou" /></h3>
+
+~~~~~~~
+
+Since thankyou.jsp is also rendered after executing the Register.java Action class, the key thankyou and its value will be available to the view page.
+
+![thankyou.png](attachments/att14975009_thankyou.png)
+
+How did the value entered for the first name input field get displayed on thankyou.jsp? Look back at the value for the thankyou key in the Register.properties file.
+
+**Register.properties**
+
+
+~~~~~~~
+thankyou=Thank you for registering %{personBean.firstName}.
+
+~~~~~~~
+
+The markup %\{personBean.firstName\} tells Struts 2 to replace this part with the result of calling getPersonBean, which returns a Person object. Then call the getFirstName method which returns a String (the value the user inputted into the personBean.firstName form field on register.jsp).
+
+__Package Level Properties__
+
+What if you want a properties file with keys and values that can be referenced from multiple view pages and those view pages are rendered after executing different Action classes? Struts 2 has the ability to use multiple property files provided the property file is found in the package hierarchy.
+
+Place the following in a file named package.properties and save that file in package org.apache.struts in src/main/resources.
+
+**package.properties**
+
+
+~~~~~~~
+greeting=Welcome to The Wonderful World of Struts 2
+
+~~~~~~~
+
+Now any view rendered by an Action that is in the hierarchy org.apache.struts... can use a Struts 2 text tag with a name attribute value of "greeting" to display the value of the greeting property key. For example add the following markup to helloworld.jsp before the h2 tag.
+
+**Using properties set in package.properties**
+
+
+~~~~~~~
+<h1><s:text name="greeting" /></h1>
+
+~~~~~~~
+
+Then rebuild the war file and deploy it to your servlet container. Go to index.action and click on the link for Hello World. You should see:
+
+![hellogreeting.png](attachments/att14975005_hellogreeting.png)
+
+The property keys and values defined in package.properties are available to any view that is rendered after executing an Action class that is the package hierarchy that includes package.properties.
+
+__Global Properties__
+
+You can also specify a global property file in struts.xml. The keys and values defined in that property file will be available to all the view pages that are rendered after executing an Action class.
+
+Add the following to a file named global.properties (note the name doesn't have to be global).
+
+**global.properties**
+
+
+~~~~~~~
+contact=For assistance contact <a href='mailto:contact@email.com'>contact@email.com</a>
+
+~~~~~~~
+
+Save the global.properties file in the src/main/resources folder.
+
+To inform the Struts 2 framework about the global.properties file add the follow node to struts.xml after the constant name="struts.devmode" node.
+
+**Specify Global Property File In struts.xml**
+
+
+~~~~~~~
+<constant name="struts.custom.i18n.resources" value="global" />
+
+~~~~~~~
+
+To use the contact key in a view page, add the following markup to index.jsp just before the closing body tag.
+
+**Using contact property**
+
+
+~~~~~~~
+<hr />
+<s:text name="contact" />
+
+~~~~~~~
+
+Rebuild the war file, deploy it to your Servlet container, and then go to index.action. You should see:
+
+![contact.png](attachments/att14975004_contact.png)
+
+Struts 2 will look for a property key of contact in all the property files starting with the property file that matches the Action class, then in the property files that are in the package hierarchy of the Action class, and then in any property files specified in struts.xml. For this example Struts 2 will find the contact key in global.properties. The value of the contact key will be displayed where we have put the text tag.
+
+You can add the text tag above to all the JSPs in this example.
+
+__Internationalization (i18n)__
+
+Using message resource files (resource bundles) also enables you to provide text in different languages. By default, Struts 2 will use the user's default locale. If that locale is en for English then the property files used will be the ones without a locale specification (for example Register.properties). If the locale is not English but say Spanish (es) then Struts 2 will look for a properties file named Register_es.properties.
+
+To provide an example of Struts 2 support for i18n create a file named Register_es.properties and in that file add the following Spanish translations.
+
+**Register_es.properties**
+
+
+~~~~~~~
+personBean.firstName=Nombre
+personBean.lastName=Apellidos
+personBean.age=Edad
+personBean.email=Correo
+thankyou=Gracias por registrarse, %{personBean.firstName}. 
+
+~~~~~~~
+
+
+
+| My apologies to Spanish language speakers for any mistakes in the Spanish translations.
+
+| 
+
+Save the Register_es.properties file in the same package as Register.properties.
+
+In our example application, we need to tell Struts 2 to use a locale value of es (since we're not in a Spanish locale) instead of the default locale value of our location (which is en). Add the following markup to index.jsp.
+
+**Specify The Locale As a URL Parameter**
+
+
+~~~~~~~
+<h3>Registro español</h3>
+<s:url action="registerInput" var="registerInputLinkES">
+    <s:param name="request_locale">es</s:param>
+</s:url>
+<p><a href="${registerInputLinkES}">Por favor, regístrese</a> para nuestro sorteo</p>
+
+~~~~~~~
+
+In the above markup we've added a parameter named request_locale to the URL. The value of that parameter is es. The Action class that responds to this URL (Register.java) will see that the locale is es and will look for property files with _es (for example Register_es.properties). It will use those property files to find the values of the property keys referenced by the view page (e.g. personBean.firstName).
+
+After clicking on the above link you should see the same form as before but with the form field labels in Spanish.
+
+![spanishform.png](attachments/att14975008_spanishform.png)
+
+If we implement the same concept by creating _es.properties versions of global.properties (global_es.properties) and package.properties (package_es.properties) then we can create a complete registration web page in Spanish. Download the finished example application for this tutorial from Google Code - [http://code.google.com/p/struts2-examples/downloads/list](http://code.google.com/p/struts2-examples/downloads/list) to see those property files and run the complete example with the registration form in Spanish.
+
+__Summary__
+
+We've covered how to use message resources (resource bundles) in Struts 2 and also introduced how Struts 2 enables internationalization (i18n) in this tutorial. To fully understand these concepts and learn more about Struts 2 consult the main Struts 2 documentation available at [http://struts.apache.org](http://struts.apache.org).

http://git-wip-us.apache.org/repos/asf/struts-site/blob/39272be0/source/getting-started/preperable-interface.md
----------------------------------------------------------------------
diff --git a/source/getting-started/preperable-interface.md b/source/getting-started/preperable-interface.md
new file mode 100644
index 0000000..02da81e
--- /dev/null
+++ b/source/getting-started/preperable-interface.md
@@ -0,0 +1,53 @@
+---
+layout: default
+title: Preperable Interface
+---
+## Preparable Interface
+
+The example code for this tutorial, preparable_interface, is available at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples).
+
+> 
+
+#####Introduction#####
+
+Often the data used to populate a form control is dynamically generated, perhaps from a database. When the user submits the form, the Struts 2 validation interceptor attempts to validate the user's form input. If validation fails the Struts 2 framework returns the value "input" but the "input" action is not re-executed. Rather the view associated with the "input" result is rendered to the user. Usually this view is the page that displayed the original form.
+
+This work-flow can cause a problem if one or more of the form fields or some other data displayed depends on a dynamic look-up that that is accomplished in the Action class's input method. Since the Action class's input method is not re-executed when validation fails, the view page may no longer have access to the correct information to create the form or other display information.
+
+
+
+| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
+
+| 
+
+#####Preparable Interface#####
+
+Struts 2 provides the [Preparable interface](http://struts.apache.org/2.3.1/xwork-core/apidocs/com/opensymphony/xwork2/Preparable.html)^[http://struts.apache.org/2.3.1/xwork-core/apidocs/com/opensymphony/xwork2/Preparable.html] to overcome this problem. An Action class that implements this interface must override the prepare method. The prepare method will always be called by the Struts 2 framework's [prepare interceptor](http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html)^[http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html] whenever any method is called for the Action class and also when validation fails before the view is rendered.
+
+In the prepare method you should put any statements that must be executed no matter what other Action class method will be called and also statements that should be executed if validation fails. Usually statements in the prepare method set the value for Action class instance fields that will be used to populate form controls and get the values that will be used to set the initial form field values.
+
+In addition to automatically running the prepare method the [prepare interceptor](http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html)^[http://struts.apache.org/2.3.1.2/docs/prepare-interceptor.html] will also call a method named prepare\[ActionMethodName\]. For example, define a prepare method and a prepareInput method in the Action class that implements preparable. When the Struts 2 framework calls the input method, the prepare interceptor will call the prepareInput and the prepare methods before calling the input method.
+
+#####Example Application#####
+
+If you examine class EditAction in the example application (see above) you'll see that it implements the Preparable Interface. In the prepare method is this code:
+
+**EditAction.java prepare Method**
+
+
+~~~~~~~
+		
+   carModelsAvailable = carModelsService.getCarModels() ;
+		
+   setPersonBean( editService.getPerson() );
+
+
+~~~~~~~
+
+The above statements get the car model values used to populate the car model check boxes displayed in the form and also get the information about the Person object being edited.
+
+When you run the example application, look in the log to see when the prepare method is called in relation to the input and execute methods. Running the example application and examining the log should help you understand the impact of implementing the Preparable Interface and the prepare method.
+
+#####Summary#####
+
+When your application requires specific statements to be executed no matter which method of the Action class is called or when validation fails, you should implement the Preparable interface and override the prepare method.


Mime
View raw message