Struts <html:cancel> Tag

In this Struts example, you will learn how to create a HTML input tag of type cancel with Struts <html:cancel> tag. In order to use the Struts HTML Tags you need to include the following taglib directive in the jsp page.

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> 

First create a new Dynamic Web Project and configure it as Maven Project. For Reference, Click Here

Add the following dependencies in pom.xml


1. Create JSP

Now we will create a HTML input tag of type cancel using Struts’s HTML tag

Write the following code in cancel.jsp

<%@taglib uri="" prefix="html"%>
<title>Struts <Html:button> Button</title>
<html:button property="button" value="Click" />

2. Struts Config

Write the following code in struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 

3. Deployment Descriptor

Now configure the deployment descriptor. Here, we have asked the container to give our ActionServlet any request that matches the pattern *.do

Add the following configuration information in the web.xml file


4. Run Project

Now when you run the project, following screen will be displayed as in Figure 25.1

Figure 25.1 Figure 25.1

The folder structure of the example is shown below in Figure 25.2

Figure 25.2 Figure 25.2

You can download the source code of this example here.


No comments yet.

Leave a Reply