Scripting in JSP

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” %>

Disabling Scripting

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.

Scriptlet elements

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:


Related Topics

JSP Custom Tag

JSP custom tag provides flexibility to programmers, to declare their own tag. Thus, a user-defined tag can be created through custom tags to perform various operations. These custom tags behave as...

2 minutes read.

JSP Tutorial

Java Server Pages (JSP) is a server-side technology used to create static and dynamic web applications. The static content is expressed by text-based format files such as HTML, XML, SVG...

2 minutes read.

JSP useBean, getProperty and setProperty tags

Java bean is a special type of Java class that contains private variables and public setter and getter methods. Java bean class implements Serializable interface and provides default constructor. JSP allows...

1 minute read.

JSP EL Implicit Objects

Apart from operators, JSP also provide expression language implicit objects. The role of these implicit objects is to get the attribute associated with various object. Here, is the list of...

1 minute read.

JSP Expression Language

JSP introduced the concept of expression language (EL) in JSP 2.0 version. The purpose of expression language is to access and manipulate data easily without using any type of scriptlet. Why...

1 minute read.

JSTL - Java Standard Tag Library

Java Standard tag library (JSTL) is a collection of various type of JSP tags. Each tag control the behavior of JSP page and perform specific task such as database access,...

1 minute read.

Scripting in JSP

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...

1 minute read.

JSP Life Cycle

JSP life cycle The life cycle of JSP page internally implemented as a Servlet. These are the following stages through which a JSP page has to pass: Translation – This is an...

2 minutes read.

JSP Page Directive

JSP page directive provides various attributes with unique properties. These attributes can be applied to an entire JSP page. The syntax of Page directive is as follows: - <@page attribute="value"> Page directive...

3 minutes read.

JSP Include Directive

As the name implies, include directive is used to include the content of other files such as HTML, JSP, text into the current JSP page. These files are included during...

1 minute read.

JSP forward and include tag

In JSP, forward and include tags are the most frequently used action tags. Unlike Servlets, there is no need to create object of RequestDispatcher interface to use the functionality of...

1 minute read.

JSTL Formatting Tags

In JSTL, the role of formatting tag is to specify the type of format that represents date and time. The following syntax represent the URL of formatting tag: - <%@ taglib...

1 minute read.

JSP config

JSP config object is used to send the configuration information to JSP page. Here, config is an instance of servlet's ServletConfig interface. In this case, the information is send to...

1 minute read.

JSTL Core Tags

In JSTL, core tags are most frequently used tags that provides variable support, manages URL and control the flow of JSP page. To use JSTL it is required to associate...

2 minutes read.

JSP Expression Tag

JSP expression tag allows you to place the result of Java expression in a convenient way. It can be seen as an alternative of out.print() method. Thus, if we want to...

1 minute read.

JSP page

In JSP, the purpose of page object is to create the servlet instance. The role of page object is similar to this keyword in Java. The page object represents the entire...

1 minute read.

JSP response

Basically, JSP response object is an instance of servlet's HttpServletResponse interface. It is used to resolve client request. Response object can be used to perform various functions such as encode...

1 minute read.

JSP Comments

JSP provides separate tag for comment section. The content inside these tag is completely ignored by JSP engine.    The syntax of comment tag is mentioned below. <%-- This is a comment...

1 minute read.

JSP Implicit Objects

In JSP, implicit objects are pre-defined objects, created by the web container. These objects are created during the translation phase from JSP to Servlet. JSP allows you to call these...

1 minute read.

JSP Control Statements

There are various standard programming languages like C, C++, Java etc. that supports control statements. On the basis of that, JSP also follows the same methodology. Let's study the flow...

2 minutes read.