user3663882
user3663882

Reputation: 7357

The purpose of %@ in jsp

I always add the following line as I write a jsp-page:

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

But what does <%@ %> mean in general? I know that we can embed code to the jsp by a scriptlet

<% \\some java code %>

So @taglib looks like an annotation being applied to the prefix. Is it correct?

Upvotes: 3

Views: 234

Answers (3)

sheetal
sheetal

Reputation: 199

It is a JSP Directive.The JSP directives are messages that tells the web container how to translate a JSP page into the corresponding servlet.The taglib directive is one of the JSP directive.The JSP taglib directive is used to define a tag library that defines many tags.

Upvotes: 0

cнŝdk
cнŝdk

Reputation: 32145

The <%@ > is a tag for JSP - Directives, that can be :

  • Page directive <%@ page ... %> : Defines page-dependent attributes, such as scripting language, error page, and buffering requirements.

  • Include directive <%@ include ... %> : Includes a file during the translation phase.

  • Taglib directive <%@ taglib ... %> : Declares a tag library, containing custom actions, used in the page.

Upvotes: 1

Master Slave
Master Slave

Reputation: 28539

Its a JSP directive

JSP directives provide directions and instructions to the container, telling it how to handle certain aspects of JSP processing. A JSP directive affects the overall structure of the servlet class. It usually has the following form:

 <%@ directive attribute="value" %>

Upvotes: 4

Related Questions