Struts 2 and tiles integration

Template: A template is a predefined pattern or format used as a guide to making something. Tile: A tile specifies a part of the whole page. Generally a website is the combination of different components or parts. Most of these parts are common on every page and mainly one part is changed (body section). If … Read more

Struts 2 s:url and s:a data tags

<s:url>: The <s:url tag is used to generate an url string. It can take parameters. Syntax: <s:url value=”urlString” var=”varName” /> <s:a>: The <s:a> tag is used to create a hyperlink. Syntax: <s:a href= Suggestion: Use s:url tag to generate url sting and then use it in the s:a tag. Example: test.jsp <%@ taglib uri="/struts-tags" prefix="s"%> … Read more

Struts 2 i18n and text data tags

<s:i18n>: The <s:i18n> tag is used to get the message from the resource bundle which is associate to an action or from any other resource. Syntax: <s:i18n name=”resourceUrl”>  Note: In case of resource bundle associate with the action, you have to create the properties file in the same package and having the same name as … Read more

Struts 2 set data tag

<s:set>: The <s:set> tag is used to set a variable value or assign a value to a variable in a specific scope. Scope can be application, session, request, page or action. Default scope actsion. Syntax: <s:set var=”varName” value=”varValue” /> Example: test.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 s:set data tag example</title> </head> <body> … Read more

Struts 2 push data tag

<s:push>: The <s:push> tag is used to push a value on the top of the stack to access it easily. Syntax: <s:push value="beanReference"> <s:propery value="property1" /> <s:propery value="property2" /> </s:push><s:push value="beanReference"> <s:propery value="property1" /> <s:propery value="property2" /> </s:push> Note: We can see in the previous s:property tag example that we have to use bean reference … Read more

Struts 2 property data tag

<s:property>: The <s:property> tag is used to get the property of a specified value. If no value is specified then it gives the property from the top of the stack. Syntax: <s:property value=”valueName”/> Example: test.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 s:property data tag example</title> </head> <body> <h3>This is a s:property data tag … Read more

Struts 2 param data tag

<s:param>: The <s:param> tag is used to pass parameters in the other tags or we can say to parameterized other tags like bean, url tags. Syntax: <s:param name=”paramName”>paramValue</s:param> Or <s:param name=”paramName” value=”paramValue” /><s:param name=”paramName”>paramValue</s:param> Or <s:param name=”paramName” value=”paramValue” /> Example: test.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 s:param data tag example</title> </head> <body> … Read more

Struts 2 date data tag

<s:date>: The <s:date> tag is used to format the date object by using custom formats or easily readable format using nice attribute. If nice attribute is set to true then it display the date in the easily readable format like an instant ago. Syntax: <s:date name=”dateField” format=”dateFormat” /> Example: index.jsp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML … Read more

Struts 2 bean data tag

<s:bean>: The <s:bean> tag is used to create an instance of a bean in your jsp page. It can take parameters to set the bean properties. After setting the bean properties value it put the bean object in the value stack to make it accessible on the jsp page. Syntax: <s:bean name="beanName" var="beanVar"> <s:param name="property1" … Read more

Struts 2 include data tag

<s:include>: The <s:include> tag is used to include the result of any other resource. Other resource can be JSP, HTML or servlet etc. It acts similar to the jsp include. Syntax: <s:include value=”resourceUrl”/>   Note: It can take parameters using s:param tag. Example: test.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Struts 2 s:include data tag example</title> … Read more