Img Tag<html:img>:



html:img Tag : Renders an HTML <img> element with the image at the specified URL. This tag allows dynamic generation of an image as specified attributes of this tag.
Note: The base URL for this image is calculated directly based on the value specified in
src, page, or action or page, or indirectly by looking up a message resource string based on the srcKey or pageKey attributes.
* There must be specified exactly one of these attributes.
Name | Description |
border |
This attribute specifies the width of the border surrounding the image. |
name |
The name attribute specifies The JSP bean that contains a |
page |
The module-relative path, starting with a slash, of the image to be
displayed by this tag. The rendered URL for this image will automatically
prepend the context path of this web application (in the same manner as
the |
action |
The action, starting with a slash, that will render the image to be
displayed by this tag. The rendered URL for this image will automatically
prepend the context path of this web application (in the same manner as
the |
property |
The name of a property of the bean specified by the |
scope |
Specified the scope within which to search for the bean specified by the |
width |
This attribute provides the width of the image being displayed. This parameter is very nice to
specify (along with |
Example Illustrating the use of the Rewrite<html:img>
tag :
Here you will learn to use the Struts Html <html:img>tags.
We will cover an example that will show a working of<html:img>tags
Example code :
Creating an Action Class
: Not Required here.
Creating Form Bean
: Not Required here.
Defining the global-forwards
: Not Required here.
Developing the Action Mapping in the struts-config.xml : Not Required here.
Developing the HtmlImageTag.jsp page :
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body bgcolor="#999933"> <h3><font color="#FFFF33">HTML IMAGE TAG DEMO</font></h3> <html:img page="/images/servicesbanner.gif" width="20%" border="2"/> </body> </html> |
Add the following line in the index.jsp to call the form.
<a href=" HtmlImageTag.jsp"> HtmlImageTagDemo</a><br/> |
Building and Testing the Example :
Build , deploy and Test the application .
Open the browser and navigate to the HtmlImageTag.jsp page.
Your browser displays the following page HtmlImageTag.jsp and see the output .
![]() |
Above Demo displays the working of <html:img>tag.


