What is the difference between <html> and <html:html> element in JSP?

I am developing a simple Struts 1.x web application and there's a file named success.jsp and this is the sample code:

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html:html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>success.jsp</title>
<html:base/>
</head>
<body>
<a href="myStart.do">Go to myStart</a>
</body>
</html:html>

By default, <html>was used instead of <html:html>, may I know what is the major difference between these two elements? Is it necessary to specify the uses of them? Besides, what is the major function for <html:base/> element?

Btw I found some definitions for these elements but I need clarification:

<html:html> Renders an HTML <html> element with language attributes extracted from the user's current Locale object, if there is one.

<html:base> Renders an HTML element with an href attribute pointing to the absolute location of the enclosing JSP page. This tag is valid only when nested inside an HTML <head> element. This tag is useful because it allows you to use relative URL references in the page that are calculated based on the URL of the page itself, rather than the URL to which the most recent submit took place (which is where the browser would normally resolve relative references against).

1 answer

  • answered 2018-11-08 21:02 Buhake Sindi

    The <html:html> tag is a Struts 1.x JSP Taglib directive, declared in this line on your JSP Page:

    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    

    These custom tag(s) are typically of the form <prefix:tagname>. The prefix declared on taglib is what binds your taglib container to the list of markups available in the taglib.

    In essence <html:html> tells the taglib, prefixed html to render a html element when JSP is rendered.

    So to answer your question <html> is a HTML directive while <html:html> is a Struts JSP taglib tag to generate a HTML <html> directive.