Sobes.tech
Junior

Why is there no need to configure standard JSP tags in the web.xml file?

sobes.tech AI

Answer from AI

Standard JSP tags, such as <jsp:useBean>, <jsp:include>, <jsp:forward>, <jsp:getProperty>, <jsp:setProperty>, <jsp:param>, and others, are part of the JSP specification and the JavaServer Pages Standard Tag Library (JSTL). These tag libraries are always available in the servlet container (such as Tomcat, Jetty, etc.) that supports the JSP specification.

Configuration in web.xml (web-app deployment descriptor) is usually required for:

  1. Declaring servlets and their URL mappings.
  2. Declaring filters and their mappings.
  3. Setting up event listeners.
  4. Defining application context parameters.
  5. Configuring custom tag libraries (not part of the standard JSTL), specifying the location of the TLD file (Tag Library Descriptor).
  6. Session settings, error pages, welcome pages, etc.

Standard JSP tags and JSTL libraries (core, fmt, sql, xml) are already "known" and processed by the JSP engine itself. Their handlers are built into the JSP implementation. Therefore, there is no need to explicitly declare them in web.xml or download additional JAR files (except perhaps for older container versions or if you want to use a specific JSTL version different from the built-in one). For standard tags, their TLD files (e.g., jsp.tld inside JSTL JAR files) are either already in the container or the container knows how to find them without explicit declaration in web.xml.

Using standard tags in JSP is done with the taglib directive:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

This directive tells the JSP engine to use the JSTL Core library with the prefix c. The uri attribute points to a unique identifier for the tag library, which the container already recognizes.