JSP Scriptlet - What is Scriptlet tag?

What are Scriptlets?

A scriptlet is a valid code in java and is placed in the jspService() method of the JSP engine at the time of running. The scriptlet syntax is -
<% java code %>


There are variables available exclusively for the scriptlets. They are request, response, out,session and pageContext, application, config and exception.

What is Scriptlet tag?

Scriptlet tag is a type tag used for inserting Java Code into JSP and it is written as follows:
<% %>

The Scriptlet tag begins with <% and ends with %>. Between these the user can add any valid Scriptlet i.e. any valid Java Code.

What is Scriptlet tag? Explain with an example.

The scriptlet tag is used to write java class statements inside the jspService() method. In other words, writing java code in a Java Server Page is done through scriptlet tag. A scriptlet tag starts with <% and ends with %>.
Example:
<% int productQty = 2719;
out.println(productQty); %>

Explain how JSP handle run-time exceptions
JSP exceptions - The errorPage attribute of the page directive can be used to redirects the browser to an error processing page, when uncaught exception...
Explain how to implement a thread-safe JSP page
JSP Thread - JSPs can be made thread-safe by having them implement the SingleThreadModel interface...
JSP implicit objects - Define implicit objects.
JSP implicit objects - These are the objects that are available for the use in JSP documents. You don’t need to declare them.....
Post your comment