Download
FAQ History |
![]() ![]() ![]() |
API
Search Feedback |
Creating Dynamic Content
You create dynamic content by accessing Java programming language object properties.
Using Objects within JSP Pages
You can access a variety of objects, including enterprise beans and JavaBeans components, within a JSP page. JSP technology automatically makes some objects available, and you can also create and access application-specific objects.
Implicit Objects
Implicit objects are created by the Web container and contain information related to a particular request, page, session, or application. Many of the objects are defined by the Java Servlet technology underlying JSP technology and are discussed at length in Chapter 15. The section Implicit Objects explains how you access implicit objects using the JSP expression language.
Application-Specific Objects
When possible, application behavior should be encapsulated in objects so that page designers can focus on presentation issues. Objects can be created by developers who are proficient in the Java programming language and in accessing databases and other services. The main way to create and use application-specific objects within a JSP page is to use JSP standard tags discussed in JavaBeans Components to create JavaBeans components and set their properties, and EL expressions to access their properties. You can also access JavaBeans components and other objects in scripting elements, which are described in Chapter 19.
Shared Objects
The conditions affecting concurrent access to shared objects described in Controlling Concurrent Access to Shared Resources apply to objects accessed from JSP pages that run as multithreaded servlets. You can indicate how a Web container should dispatch multiple client requests with the following
page
directive:When
isThreadSafe
is set totrue
, the Web container may choose to dispatch multiple concurrent client requests to the JSP page. This is the default setting. If usingtrue
, you must ensure that you properly synchronize access to any shared objects defined at the page level. This includes objects created within declarations, JavaBeans components with page scope, and attributes of the page context object (see Implicit Objects).If
isThreadSafe
is set tofalse
, requests are dispatched one at a time, in the order they were received, and access to page level objects does not have to be controlled. However, you still must ensure that access to attributes of theapplication
orsession
scope objects and to JavaBeans components with application or session scope is properly synchronized.
Note: The Servlet 2.4 specification deprecates
SingleThreadModel
, which is the most common mechanism for Web containers to implementisThreadSafe
. You are advised against usingisThreadSafe
, as the generated servlet may contain deprecated code.
Download
FAQ History |
![]() ![]() ![]() |
API
Search Feedback |
All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.