Struts <html:reset> Tag

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

Write the following code in reset.jsp

<%@taglib uri="" prefix="html"%>
<title>Struts <Html:reset> Button</title>
<html:reset value="Reset" />

Now create another JSP output.jsp that display the dropdown value. Write the following code in output.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="" prefix="bean"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Output Page</title>
       Selected Fruit - <bean:write name="StrutsDropDownForm" property="fruit" />

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 26.1

Figure 26.1 Figure 26.1

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

Figure 26.2 Figure 26.2

You can download the source code of this example here.


No comments yet.

Leave a Reply