JSP scripting provides an easy and efficient way to insert Java programming language in JSP pages. Here, Java is a default language.
JSP also allows you to use any other scripting language that is capable to call Java objects. In this case, you have to specify that language in the page directive. The following syntax is used to implement it.
<%@ page language = “Scripting-language” %>
It is not mandatory to use scripting in JSP page. So, JSP allows you to disable scripting if it is not required. Although, by default scripting is always enable.
In JSP scripting, scriptlet elements perform the actual task. Hence, Java statements are enclosed within these elements.
JSP scripting elements are capable to create and manipulate Java objects, declaring variables and methods, catching Java Exceptions etc. It enables the JSP page to connect with database and fetch queries.
JSP provides three types of scripting elements to embed Java code in JSP page. Each scripting element has its own purpose. The following scripting elements are:
- Scriptlet tag
- Declaration tag
- Expression tag