JSP Scripting Tags(Elements)

There are three language-based types of scripting elements

JSP scripting elements allow you to use Java programming language statements in your JSP pages. Scripting elements are typically used to create and access objects, define methods, and manage the flow of control. Many tasks that require the use of scripts can be eliminated by using custom tag libraries, in particular the JSP Standard Tag Library.

There are three ways to create and use objects in scripting elements:

● Instance and class variables of the JSP page’s servlet class are created in declarations and accessed in scriptlets and expressions.
● Local variables of the JSP page’s servlet class are created and used in scriptlets and expressions.
● Attributes of scope objects (see Using Scope Objects) are created and used in scriptlets and expressions.


This chapter briefly describes the syntax and usage of JSP scripting elements.

Using Scripting

JSP technology allows a container to support any scripting language that can call Java objects. If you wish to use a scripting language other than the default, java, you must specify it in the language attribute of the page directive at the beginning of a JSP page:

<%@ page language="scripting-language" %>

Because scripting elements are converted to programming language statements in the JSP page's servlet class, you must import any classes and packages used by a JSP page. If the page language is java, you import a class or package with the import attribute of the page directive:

<%@ page import="fully-qualified-classname, packagename.*" %>

The webclient JSP page response.jsp uses the following page directive to import the classes needed to access the service classes:

<%@ page import= "helloservice.endpoint.HelloService, helloservice.endpoint.Hello" %>

Disabling Scripting

By default, scripting in JSP pages is valid. Because scripting can make pages difficult to maintain, some JSP page authors or page authoring groups may want to follow a methodology in which scripting elements are not allowed.

You can disable scripting for a group of JSP pages in an application in one of two ways:

● Select the Ignore Java Script check box in the JSP Property Group node of the NetBeans IDE web.xml editor.
● Set the scripting-invalid element of the application’s deployment descriptor to true. The scripting-invalid element is a child of the jsp-property-group element that defines properties for a set of JSP pages.
● For information on how to define a group of JSP pages, see Setting Properties for Groups of JSP Pages. When scripting is invalid, it means that scriptlets, scripting expressions, and declarations will produce a translation error if present in any of the pages in the group. Table 9-1 summarizes the scripting settings and their meanings.

Scripting Settings

JSP ConfigurationScripting Encountered
UnspecifiedValid
falseValid
trueTranslation Error
there are three language-based types of scripting elements:

● Expresdsion
● Declarations
● Scripting

Declarations follows the syntax<%!....%>.
Scripting follows the syntax<%=.....%>.
Expresdsion follows the syntax<%=....%>.
Expresdsion follows the syntax<%=....%>.


References : oracle « Privious Post » « Next Post » share on :        :  

Love to hear your Views / Guidance / Recommendations on this Post…

Explore the Technology World

The mind behind Linux & GIT : Linus TorvaldsLinus Torvalds transformed technology twice — first with the Linux kernel, which helps power the Internet, and again with Git, the source code management syst ...Read MoreTensorflow and deep learningWith Tensorflow ,deep machine learning transitions from an area of research into mainstream software engineering. ...Read MoreJava program to return all possible permutations from collection of distinct numbersexample of Java program to return all possible permutations from collection of distinct numbers ...Read MoreReal Time Analytics with Spring Application Development FrameworkSpring is the most popular application development framework for enterprise Java.Millions of developers use Spring to build simple, truly portable, fast and fle ...Read MorePath Setting in Java When an application is launched from command prompt Windows OS searches for the executable program in the current working directory. The prompt throws an error ...Read MorePicture-in-Picture App for Android devices with Source CodePicture-in-Picture is a special type of multi-window mode mostly used for video playback for Android devices.Released under Apache License 2.0 , which means you ...Read MoreFacebook |Google+ | Twitter | LinkedIn | Youtube About | Cookies-Policy | Disclaimer | Site Map | Contact

Call / Visit for New Batch

Services

Why Join Us

  • ➯ Free Demo Classes
  • ➯ No Registration Fee
  • ➯ Interview Questions
  • ➯ Study Materials
  • ➯ Softwares
  • ➯ Aptitude & Reasoning
  • ➯ Placement Assitance

Address

  • MyJava Training Institute ,
  • Plot No.243 , shop No 14 ,
  • Secnd Floor , Zone-II ,
  • M.P.Nagar , Bhopal,
  • Madhya Pradesh ( 462011 )
  • ☎  08871209400 , 7987028543
  • 🌐 www.myjava.in
FacebookGoogle +TwitterYouTube

MyJava - java Training Institute