IfControlTag.jsp
------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:set name="Name" value="%{'Gyan'}" />
<s:if test="%{#Name=='Singh'}">You Working with--
<div><s:property value="%{#Name}" /></div>
<div>Your Name is Gyan</div>
</s:if>
<s:elseif test="%{#Name=='Gyan'}">You Working with--
<div><s:property value="%{#Name}" /></div>
<div>My Name is Gyan</div>
</s:elseif>
<s:else>for false condition
<div>Your Name is Not Specified</div>
</s:else>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------
index.jsp
---------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>If Control Tag</title>
</head>
<body>
<ul>
<li><a href="IfControlTag.jsp">IF Control Tag Example</a></li>
</ul>
</body>
</html>
---------------------------------------------------------------------------------------------------------------------
Result.java
-------------------
package kites;
import com.opensymphony.xwork2.ActionSupport;
public class Result extends ActionSupport{
public String execute() throws Exception {
return SUCCESS;
}
}
-----------------------------------------------------------------------------------------------------------------------
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.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />
<package name="kites" extends="struts-default" namespace="/">
<action name="Result" class="kites.Result" >
<result name="SUCCESS">/IfControlTag.jsp</result>
</action>
</package>
</struts>
---------------------------------------------------------------------------------------------------------------------
------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:set name="Name" value="%{'Gyan'}" />
<s:if test="%{#Name=='Singh'}">You Working with--
<div><s:property value="%{#Name}" /></div>
<div>Your Name is Gyan</div>
</s:if>
<s:elseif test="%{#Name=='Gyan'}">You Working with--
<div><s:property value="%{#Name}" /></div>
<div>My Name is Gyan</div>
</s:elseif>
<s:else>for false condition
<div>Your Name is Not Specified</div>
</s:else>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------
index.jsp
---------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>If Control Tag</title>
</head>
<body>
<ul>
<li><a href="IfControlTag.jsp">IF Control Tag Example</a></li>
</ul>
</body>
</html>
---------------------------------------------------------------------------------------------------------------------
Result.java
-------------------
package kites;
import com.opensymphony.xwork2.ActionSupport;
public class Result extends ActionSupport{
public String execute() throws Exception {
return SUCCESS;
}
}
-----------------------------------------------------------------------------------------------------------------------
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.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />
<package name="kites" extends="struts-default" namespace="/">
<action name="Result" class="kites.Result" >
<result name="SUCCESS">/IfControlTag.jsp</result>
</action>
</package>
</struts>
---------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment