JSP Scripting Elements - Explain JSP Scripting Elements

Explain JSP Scripting Elements.

There are three forms of JSP scripting elements that let you insert Java code into the servlet.

a. JSP Expressions take the form : <%= Java Expression %>
A JSP expression is used to insert Java values directly into the output. The Java expression is evaluated, converted to a string, and inserted in the page.

b. JSP Scriptlets take the form : <% Java Code %>
A JSP scriptlets let you insert arbitrary code into the servlet method that will be built to generate the page.This helps when something more complex than just a simple insertion expression is needed.

c. JSP declaration take the form : <% and ends with %>
A JSP declaration lets you define methods or fields that get inserted into the main body of the servlet class (outside of the service method processing the request). They are normally used in conjunction with JSP expressions or Scriptlets, since declarations do not generate any output.

Explain JSP Scripting Elements.

The scripting elements of a Java Server Pages are utilized to perform server-side operation in a JSP. JSP scripting elements are also called as scriptlets and performs java and javascript functionality. These are enclosed between <% and %> . All the scripting elements are processed by JRun.
<% Date today = new Date(); %>
In the above example the 'Date' class object is created and assigned to the reference variable 'today'.
Difference between JSP include directive and JSP include action.
JSP include directive - When a JSP include directive is used, the included file's code is added into the added JSP page at page translation time...
JSP Declaration - What is a Declaration?
JSP Declaration - A declaration consists of one or more variables or methods that are used in JSP source file....
Explain how to use JavaBeans components (beans) from a JSP page
The JSP specification includes standard tags for bean use and manipulation..
Post your comment