Struts HTML Tag Library
Struts HTML tag library provides tags which are used to create input forms and HTML user interfaces. The tags in the Struts HTML library form a bridge between a JSP view and the other components of a Web application. Since a dynamic Web application often depends on gathering data from a user, input forms play an important role in the Struts framework. Consequently, the majority of the HTML tags involve HTML forms.
Syntax to use Struts HTML tag library
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
< html:img >
< html:img > -Renders an HTML < img> element with the image at the specified URL. Like the link tag, URL rewriting will be applied automatically to the value specified in src, page, or action to maintain session state in the absence of cookies. This will allow dynamic generation of an image where the content displayed for this image will be taken from the attributes of this tag.
Example Code for < html:img >
1.Create an Jsp page and name it as img.jsp.To illustrate < html:img> tag we require only one simple jsp page which contains this tag.this tag does not require to be nested in form tag.
img.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %> <%@taglib prefix="bean" uri="http://jakarta.apache.org/struts/tags-bean" %> < html> < head> < title> HTML Img example </title> < head> < body > < h1 > Struts html:img example </h1> < html:img src="images/apache-struts-logo.jpg" alt="Struts Logo" /> </body> </html>
2.Building and running the Jsp page
Output
Access page:http://localhost:8084/img.jsp
also read: