XSL Result and its example
Posted on: January 19, 2011 at 12:00 AM
In this tutorial you will learn how to use XSLT result in struts2 for displaying data from JSP

XSL Result and its example

XSLT stands for XSL Transformations. It is the most important part of XSL. XSLT is a language which is used for transforming the XML document into other XML document or the language which browser recognize such as HTML, XHTML. With the XSLT you can rearrange or sort document, remove or add the attribute from the output file.

An Example of XSLT result is given below


<%@ taglib uri="/struts-tags" prefix="s"%>
<s:form action="submit" method="Post">
<td><s:textfield key="name" label="Specify Your Name "/></td>

<td><s:textfield key="address" label="Specify Your Address "/></td>

<td colspan="2"><s:submit value="OK"/></td>


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>
<xsl:template match="result">
<h2>XSLT Result Example</h2>

<h4>Name : <xsl:value-of select="name"/></h4>
<h4>Address :<xsl:value-of select="address"/></h4>




package net.roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class XSLTResult extends ActionSupport{
	private String name;
	private String address;
	public String getName() {
		return name;

	public void setName(String name) {
		this.name = name;

	public String getAddress() {
		return address;

	public void setAddress(String address) {
		this.address = address;

	public String execute() throws Exception {
		String control=INPUT;
		// TODO Auto-generated method stub
		if((getName()!=null && getName().length()>0) && (getAddress()!=null && getAddress().length()>0)){
		return control;


<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


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

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

<action name="submit" class="net.roseindia.XSLTResult">
<result type="xslt" name="success">
<param name="stylesheetLocation">/jsp/result.xslt</param>
<param name="matchingPattern">^/result/[^/*]$</param>
<result name="input">/jsp/index.jsp</result>


When you run this application it will display message as shown below:


Download this example code

Related Tags for XSL Result and its example:




Advertisement null