Struts <html:button> Tag

In this Struts example, you will learn how to create a HTML input tag of type button with Struts <html:button> 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

Let us create an Action class that will handle the request.

Write the following code in button.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 24.1

Figure 24.1 Figure 24.1

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

Figure 24.2 Figure 24.2

You can download the source code of this example here.


No comments yet.

Leave a Reply