ProAnswers.org

What are different type of scripting elements in JSP?

Declaration Element:
is the embedded Java declaration statement, which gets inserted at the Servlet class level.

Important: declaring variables via this element is not thread-safe, because this variable ends up in the generated Servlet as an instance variable, not within the body of the _jspservice() method. Ensure their access is either read-only or synchronized.

Expression Element:
is the embedded Java expression, which gets evaluated by the service method.

Scriptlet Elements:
are the embedded Java statements, which get executed as part of the service method.
(Note: Not recommended to use Scriptlet elements because they don’t provide reusability and maintainability. Use custom tags (like JSTL, JSF tags, etc) or beans instead).

Action Elements:
A JSP element that provides information for execution phase.

Directive Elements:
A JSP element that provides global information for the translation phase.