[an error occurred while processing this directive]

JSP Elements

                         

A JSP page can have two types of data:

  • Template Data: It is the static part of a jsp page. Anything that is copied as it is directly to the response by the JSP server is known as template data.
  • JSP Elements: It is the dynamic part of a jsp page. Anything that is translated and executed by the JSP server is known as JSP element.

There are three types of JSP elements:

Directive Elements: The directive elements, contains the information about the page itself that remains the same between requests for the page. The general directive syntax is:

<%@ directiveName attr1="value1" attr2="value2" %>

The directive name and all attribute names are case-sensitive and the attribute values can be enclosed with single quotes instead of double quotes.

Action Element: Action elements generally performs some action depending on the information required at when the JSP page is requested by a browser. An action can access parameters sent with the request in order to lookup the database.

The general syntax for the action elements is:

<action_name attribute=value ...>action_body</action_name>
<action_name attribute=value .../>

Scripting Element: A JSP element is an element that provides embedded Java statements. A JSP page can have three types of scripting elements:

  • Declaration Element: A JSP element provides the capability of inserting Java declaration statements into the Servlet class. Here is the syntax for the declaration element.

         <%! Java decalaration statements %>

  • Scriptlet Element: A JSP element provides the capability of embedding Java expressions to be evaluated as part of the service method of the Servlet class. An scripting element can be written in two ways:

        <% Java statements %>

  • Expression Element: A JSP element provides the capability of embedding Java expressions to be evaluated as part of the service method of the Servlet class. An expression element can be written in two ways:

    <% Java expressoins %>

                         

[an error occurred while processing this directive]