Pages Navigation Menu

Coding is much easier than you think

Struts 2 Debug Tag Example

Struts 2 Debug Tag Example


In Struts 2, the “debug” tag is used to output the content of the “Value Stack” and Stack Context details in the web page.
** UPDATE: Struts 2 Complete tutorial now available here.
1. Jsp debug tag example
A JSP page to output the system’s “Value Stack” and “Stack Context” using debug tag.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@taglib uri="/struts-tags" prefix="s"%>
<title>Debug tag</title>
<h3>Debug tag</h3>
<s:debug />

2. Action class
A Action class, with a field named actionProperty” property, show in value stack in jsp.

package com.simplecode.action;
import com.opensymphony.xwork2.Action;

public class DebugTag implements Action
	public String actionProperty;

	public String getActionProperty() 
		return actionProperty;

	public void setActionProperty(String actionProperty) 
		this.actionProperty = actionProperty;

3. 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="default" extends="struts-default">
	<action name="debugTagAction" class="com.simplecode.action.DebugTag">
		<result name="success">/debug.jsp</result>

4. Demo


The <s:debug /> will generate a text link named “debug“, On clicking this link, it expands to show the debugging details.


struts debug tag

Download It –


About Mohaideen Jamil

Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.