Web Technologies - Old Questions

13.  Write short notes on:

a.       HTML DOM

b.       Tag libraries


5 marks | Asked in 2071-II

a. HTML DOM

The HTML DOM is an Object Model for HTML. It defines:

  • HTML elements as objects
  • Properties for all HTML elements
  • Methods for all HTML elements
  • Events for all HTML elements

When a web page is loaded, the browser creates a Document Object Model of the page. The HTML DOM model is constructed as a tree of Objects:

DOM HTML tree

b. Tag libraries 

In a Web application, a common design goal is to separate the display code from business logic. Java tag libraries are one solution to this problem. Tag libraries allow you to isolate business logic from the display code by creating a Tag class (which performs the business logic) and including an HTML-like tag in your JSP page. When the Web server encounters the tag within your JSP page, the Web server will call methods within the corresponding Java Tag class to produce the required HTML content.

A tag library defines a collection of custom actions. The tags can be used directly by developers in manually coding a JSP page, or automatically by Java development tools. A tag library must be portable between different JSP container implementations.

A custom tag library is made accessible to a JSP page through a taglib directive of the following general form:

<%@ taglib uri="URI" prefix="prefix" %>