Struts HTML Img Tag ( < html:img >)

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="" %>

< 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.


 <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="html" uri="" %>
<%@taglib prefix="bean" uri="" %>

< 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" />

2.Building and running the Jsp page


Access page:http://localhost:8084/img.jsp

also read:

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!