Example of struts2.2.1 bean tag.
Posted on: January 3, 2011 at 12:00 AM
In this section, you will see the use of bean tag of struts2.

Example of struts2.2.1 bean tag.

In this tutorial, you will see the use of bean tag of struts2.2.1 tag. The Bean tag is a generic tag that is used to instantiates a class that confirms to the JavaBeans specification. This tag has a body which can contain a number of Parma elements to set any mutator methods on that class.

Directory structure of anchor tag example.

 1- index.jsp  

<html>ADS_TO_REPLACE_1

<head><title>Insert title here</title></head>

<body>

<h1>Example of bean tag.....</h1>ADS_TO_REPLACE_2

<a href="beanAction.action"> Convert Paisa into Rupees..</a>

</body>

</html>

2-beanActionClass.java ADS_TO_REPLACE_3

package roseindia.action ;

import com.opensymphony.xwork2.ActionSupport;

public class beanActionClass extends ActionSupport {ADS_TO_REPLACE_4

public String execute() throws Exception{

return SUCCESS;}

}

4_beanActionClass.java

package roseindia.action ;ADS_TO_REPLACE_5

import com.opensymphony.xwork2.ActionSupport;

public class beanActionClass extends ActionSupport {

public String execute() throws Exception{ADS_TO_REPLACE_6

return SUCCESS;}

}

5_ConvetPaisaIntoRupees.java

package roseindia.javabean;

public class ConvetPaisaIntoRupees {ADS_TO_REPLACE_7

private float paisa; private float rupees;

public float getPaisa()

{ADS_TO_REPLACE_8

return (rupees*100);

}

public void setPaisa(float paisa)ADS_TO_REPLACE_9

{

this.paisa = paisa;

}ADS_TO_REPLACE_10

public float getRupees()

{

return (paisa/100);ADS_TO_REPLACE_11

}

public void setRupees(float rupees)

{ADS_TO_REPLACE_12

this.rupees = rupees;}

}

 6_struts.xml

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

<action name="beanAction" class="roseindia.action.beanActionClass">ADS_TO_REPLACE_13

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

</action>

</package>

3_ welcome.jsp ADS_TO_REPLACE_14

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

<html>

<head><title>Insert title here</title></head>ADS_TO_REPLACE_15

<body><h1>Value of paisa into rupee </h1>

<s:bean name="roseindia.javabean.ConvetPaisaIntoRupees">

<s:param name="paisa" value="100" />ADS_TO_REPLACE_16

100 Paisa = <s:property value="rupees" /> Rupees

</s:bean></body>

</html> ADS_TO_REPLACE_17

index.jsp

ValueofPaisaInRupee.jspADS_TO_REPLACE_18

Download Select Source Code


Related Tags for Example of struts2.2.1 bean tag.:

Advertisements

Ads

 
Advertisement null

Ads