Struts 2 Data tages

1. url tag:- The url tag is a tag responsible for generating URL strings using struts tag lib. The advantage of this is that you can supply parameters to the tag. Let take an example to show the usage of url tag.


Example usage is:-

Create the dynamic web project from new project in elipse and then create the following files:-


Step 1:- Create


package r4r;

import com.opensymphony.xwork2.ActionSupport;

public class WelcomeAction extends ActionSupport{

private static final long serialVersionUID = 1L;

private String name;

public static long getSerialversionuid() {

return serialVersionUID;


public String execute() throws Exception {

return "success";


public String getName() {

return name;


public void setName(String name) { = name;




Step 2:- Create view welcome.jsp


<%@ page contentType="text/html; charset=UTF-8"%>

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



<title>Hello World</title>



<s:url id="login" action="login" var="myurl">

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


<a href='<s:property value="#myurl"/>'>

<s:property value="#myurl"/></a>




Step 3:- Create web.xml


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="" xmlns="" xsi:schemaLocation="" version="3.0">
















Step 4:- Create struts.xml


<?xml version="1.0" encoding="UTF-8"?>


"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"



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

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

<action name="Student"



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





you can download the project from here