Home Struts Struts Struts2.2.1 Tags Struts2.2.1 token tag example.

Ask Questions?

View Latest Questions


 
 

Struts2.2.1 token tag example.
Posted on: January 17, 2011 at 12:00 AM
Advertisement
In this example, you will see the use of struts token tag.

Struts2.2.1 token tag example.

In this example, you will see the use of taken tag of struts2.2.1. It helps double click problem. The s:token tag merely places a hidden element that contains the unique token.

 1- index.jsp

<%@ taglib uri="/struts-tags" prefix="s" %>

<html>

<head><title>Struts_Token_Example</title></head>

<body><h1>Struts_Token_Example</h1><hr/>

<s:form action="tokenAction">

<s:textfield label="Name" name="name"></s:textfield>

<s:textfield name="age" label="Age"></s:textfield>

<s:token name="token"></s:token>

<s:submit></s:submit>

</s:form></body>

</html>

2_ TokenAction.java

package roseindia.action;

import com.opensymphony.xwork2.ActionSupport;

public class TokenAction extends ActionSupport {

private String name;

private String age; 

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getAge() {

return age;

}

public void setAge(String age) {

this.age = age;

}

public String execute() throws Exception {

return SUCCESS;  }

}

3_ struts.xml

<struts>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="false" />

<package name="roseindia" extends="struts-default" namespace="/">

<action name="tokenAction" class="roseindia.action.TokenAction">

<interceptor-ref name="token" />

<interceptor-ref name="basicStack"/>

<result name="success" >/success.jsp</result>

<result name="invalid.token">/index.jsp</result>

</action>

</package>

</struts>

4_ success.jsp

<%@ taglib uri="/struts-tags" prefix="s" %>

<html>

<head><title>Struts_Token_Example</title>

</head>

<body><h1>Struts_Token_Example</h1><hr/>

Name : <s:property value="name"/><br>

Age : <s:property value="age"/>

</body>

</html>

index.gif

value.gif

success.gif

 

Download Select Source Code


Related Tags for Struts2.2.1 token tag example.:


DMCA.com