2.8. Session management



Similar documents
Pure server-side Web Applications with Java, JSP. Application Servers: the Essential Tool of Server-Side Programming. Install and Check Tomcat

Servlets. Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun

Class Focus: Web Applications that provide Dynamic Content

2. Follow the installation directions and install the server on ccc

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

SSC - Web applications and development Introduction and Java Servlet (II)

Web Container Components Servlet JSP Tag Libraries

Database Applications Recitation 10. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Managing Data on the World Wide-Web

chapter 3Chapter 3 Advanced Servlet Techniques Servlets and Web Sessions Store Information in a Session In This Chapter

Application Security

Outline. Lecture 9: Java Servlet and JSP. Servlet API. HTTP Servlet Basics

Session Tracking Customized Java EE Training:

Principles and Techniques of DBMS 5 Servlet

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, Java Servlets

ACM Crossroads Student Magazine The ACM's First Electronic Publication

Hello World RESTful web service tutorial

INTRODUCTION TO WEB TECHNOLOGY

11.1 Web Server Operation

Creating Java EE Applications and Servlets with IntelliJ IDEA

An introduction to web programming with Java

BAPI. Business Application Programming Interface. Compiled by Y R Nagesh 1

Agenda. Summary of Previous Session. Application Servers G Session 3 - Main Theme Page-Based Application Servers (Part II)

Java 2 Web Developer Certification Study Guide Natalie Levi

Outline. CS 112 Introduction to Programming. Recap: HTML/CSS/Javascript. Admin. Outline

Implementing the Shop with EJB

Ch-03 Web Applications

Web Programming II JSP (Java Server Pages) ASP request processing. The Problem. The Problem. Enterprise Application Development using J2EE

Java Server Pages and Java Beans

Java Servlet and JSP Programming. Structure and Deployment China Jiliang University

Exam Prep. Sun Certified Web Component Developer (SCWCD) for J2EE Platform

How to use JavaMail to send

CS506 Web Design and Development Solved Online Quiz No. 01

Manual. Programmer's Guide for Java API

JSP Java Server Pages

Introduction to J2EE Web Technologies

Intellicus Single Sign-on

Web Applications. For live Java training, please see training courses at

JAVASCRIPT AND COOKIES

Controlling Web Application Behavior

Java Servlet Tutorial. Java Servlet Tutorial

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Penetration from application down to OS

7 Web Databases. Access to Web Databases: Servlets, Applets. Java Server Pages PHP, PEAR. Languages: Java, PHP, Python,...

COMP9321 Web Applications Engineering: Java Servlets

Recommended readings. Lecture 11 - Securing Web. Applications. Security. Declarative Security

Building Web Applications, Servlets, JSP and JDBC

PA165 - Lab session - Web Presentation Layer

Web Application Programmer's Guide

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Contents. 2 Alfresco API Version 1.0

Getting Started with Web Applications

Novell Identity Manager

CONTROLLING WEB APPLICATION BEHAVIOR WITH

Java Server Pages (JSP)

Web Programming with Java Servlets

Java 2 Platform, Enterprise Edition (J2EE) Bruno Souza Java Technologist, Sun Microsystems, Inc.

CHAPTER 9: SERVLET AND JSP FILTERS

Sample HP OO Web Application

Security Code Review- Identifying Web Vulnerabilities

InternetVista Web scenario documentation

WIRIS quizzes web services Getting started with PHP and Java

JSP. Common patterns

Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.

No no-argument constructor. No default constructor found

Online signature API. Terms used in this document. The API in brief. Version 0.20,

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

Complete Java Web Development

Web Applications and Struts 2

Real SQL Programming 1

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

Web Application Development on a Linux System With a DB2 Database By Alan Andrea

Website as Tool for Compare Credit Card Offers

DTS Web Developers Guide

AN OVERVIEW OF SERVLET AND JSP TECHNOLOGY

NGASI AppServer Manager SaaS/ASP Hosting Automation for Cloud Computing Administrator and User Guide

In this chapter the concept of Servlets, not the entire Servlet specification, is

Please send your comments to:

1 Introduction. 3 Open Mobile IS components 3.1 Embedded Database 3.2 Web server and Servlet API 3.3 Service API and template engine

White Paper March 1, Integrating AR System with Single Sign-On (SSO) authentication systems

Forms, CGI Objectives. HTML forms. Form example. Form example...

Arjun V. Bala Page 20

Java Server Pages combined with servlets in action. Generals. Java Servlets

Working With Virtual Hosts on Pramati Server

<Insert Picture Here>

Virtual Credit Card Processing System

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE

NetIQ Access Manager. Developer Kit 3.2. May 2012

JWIG Yet Another Framework for Maintainable and Secure Web Applications

Liferay Enterprise ecommerce. Adding ecommerce functionality to Liferay Reading Time: 10 minutes

Transcription:

2.8. Session management Juan M. Gimeno, Josep M. Ribó January, 2008

Session management. Contents Motivation Hidden fields URL rewriting Cookies Session management with the Servlet/JSP API Examples Scopes 1

Sessions. Motivation Motivation: HTTP: A stateless protocol When a client sends a request, the server sends back a response but does not keep any information about that request and the client state. In most web applications a client has to access various pages before completing a specific task and the client state should be kept along all those pages Example 1: A customer wants to buy some items in an on-line store. She/he should add each one of them to his/her shopping cart and, at the end, pay for them in order to complete the purchase Example 2: A customer wants to make a reservation for a specific performance: he/she should choose the performance, the city, the theater in which it takes place, the schedule, the seat and, finally buy one or more tickets for that specific performance Both examples involve a conversation between the customer and the web application (at the server side). The server must maintain, at every moment, the client s conversational state (i.e., the information that the client has sent to the server along his/her interaction with the web application) How to remember the client s conversational state using a stateless protocol? 2

Sessions. Motivation Keeping client information between pages In a web application we may maintain the client state by means of different techniques Hidden fields URL rewriting Cookies Servlet and JSP API 3

Sessions. Hidden fields Hidden fields Idea: The client state is passed from the server to the client and back to the server in a hidden field of a form <% int n; if (request.getparameter("counter")==null) n=1; else{ n=integer.parseint(request.getparameter("counter"))+1; } %> <html> <h1>page counter using hidden fields</h1> <form action="index.jsp" method="get" > This is your access number <%=n%> <p> <input type="hidden" name="counter" value=<%=string.valueof(n)%>> <input type="submit" value="new access"> </form> </html> Example location: sessions/examples/ex1 4

Sessions. URL rewriting URL rewriting Idea: The client state is passed from the server to the client and back to the server in the query string, accompanying the URL <% int n; if (request.getparameter("counter")==null) n=1; else{ n=integer.parseint(request.getparameter("counter"))+1; } %> <html> <h1>page counter using URL rewriting</h1> This is your access number <%=n%> <p> <a href="index.jsp?counter=<%=string.valueof(n)%>"> New access</a> </html> Example location: sessions/examples/ex2 5

Sessions. Cookies Cookies A cookie is a pair (key-string,value-string) which is: Sent by the server to the client as a part of the response to a client request, Stored by the client browser (when it receives the cookie from the server) and Sent back by the client as a part of subsequent requests to the same server Example of cookie: (accessnb,"12") 6

Sessions. Cookies Cookies (2) Cookies can be used to store the state reached by the client in the previous request so that it can be restored in the next one Example: The cookie (accessnb, 12 ) may mean that as a consequence of the last request (acces to a page p) the number of accesses to p has been 12 When the client sends another reques to access p the server will increase that number by one and will send the new cookie (accessnb, 13 ) to the client 7

Sessions. Cookies Cookies features Cookies are stored in the client browser as pairs (string-key, string-value). Each pair is associated to a URL domain Cookies have an expiration date. client state will be lost After that date, the Cookies are not a universal way to store the client state (e.g., the client may disable cookies) Cookies are usually used in two situations: Remmember client preferences (e.g., client language) Support to session management (see below) 8

Sessions. Cookies Cookies. API Java provides support for cookies. In particular: It defines the class Cookie It provides operations to get the cookies from the client request (request.getcookies()) and to add cookies to the server response (response.addcookie(...)) 9

Sessions. Cookies Cookies. API. The class Cookie Summary of the Cookie class operations Cookie(java.lang.String name, java.lang.string value) Constructs a cookie with a specified name and value. java.lang.string getname() Returns the name of the cookie. java.lang.string getname() Returns the name of the cookie. java.lang.string getpath() Returns the path on the server to which the browser returns this cookie. java.lang.string getvalue() Returns the value of the cookie. void setmaxage(int expiry) Sets the maximum age of the cookie in seconds. void setpath(java.lang.string uri) Specifies a path for the cookie to which the client should return the cookie. void setvalue(java.lang.string newvalue) Assigns a new value to a cookie after the cookie is created. 10

Sessions. Cookies Cookies. API. Cookies support in other classes Interface HttpServletRequest Cookie[] getcookies() Returns an array containing all of the Cookie objects the client sent with this request. Interface HttpServletResponse void addcookie(cookie cookie) Adds the specified cookie to the response. 11

Sessions. Cookies Cookies. An access counter Example location: sessions/examples/ex3 File index.jsp <% final int YEARSECS=60*60*24*365; int n; Cookie[] cookies=request.getcookies(); String accessnb=null; if (cookies!=null){ for (int i=0; i<cookies.length;i++){ Cookie c=cookies[i]; if ((c.getname()).equals("accessnb")) accessnb=c.getvalue(); } } if (accessnb==null){ n=1; } else{ n=integer.parseint(accessnb); } Cookie c=new Cookie("accessNb",String.valueOf(n+1)); c.setmaxage(yearsecs); response.addcookie(c); %>... 12

Sessions. Cookies Cookies. An access counter (2)...continuation <html> <h2> Access counter </h2> <p> This is a version without session support. A cookie is used to store (in the client side) the value of the last access number <p> <p> This is your access number <%=n%> <p> Click <a href="index.jsp"> here </a> </html> 13

Sessions. Servlet and JSP API Servlet and JSP API. Session management Idea of sessions: 1. The client sends a request to the server 2. The server creates a session which will encompass all the interactions with that client in the next few minutes. This session is identified with a session identifier 3. The server manages the client request and elaborates a response to its request. 4. This management may remember some objects which will be retrieved by later requests of the same session. These remembered objects: are called attributes are associated to the session can be retrieved using a key (string) 14

Sessions. Servlet and JSP API Servlet and JSP API. Session management 5. When the server has finished managing the request, the server sends to the client: its response (html/xml code) a cookie with the session identifier (sid) 6. When the client sends another request to the same server, it includes the cookie (with the identifier sid) that received from it. In this way the server can identify the session. 7. The server manages the new request. In particular, it may retrieve the session attributes which were set in the last session access. 15

Sessions. Servlet and JSP API CLIENT SERVER http request: "counter.jsp" counter_jsp.class is executed: *Create a session identifier (sid) *Create a cookie JSESSIONID=sid *Add the cookie to the server response *Manage the request and set session attributes: session.setattribute("counter",new Integer(1)); http response: Cookie:JSESSIONID=sid; html page http request: Cookie:JSESSIONID=sid; "counter.jsp" counter_jsp.class is executed: *Get the session identifier obtained from the request (sid): session=request.getsession(); *Manage the session: Get/Set session attributes: session.getattribute("counter"); 16

Sessions. Servlet and JSP API Session management. API The following classes and interfaces are provided by the Servlet and JSP API in order to manage sessions: HttpSession HttpServletRequest HttpServletResponse Cookie In order to trace objects that are incorporated and/or removed from a session or activation/remove of the own session, the API offers the following classes and interfaces (however, these classes are not presented in these slides): HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionListener, HttpSessionBindingListener, HttpSessionBindingEvent, HttpSessionEvent 17

Sessions. Servlet and JSP API Session management. Use of the API A servlet/jsp page which manages a request which needs session support must do the following: 1. Session creation/identification Identify an already created session which can be associated to that request (or create a session for that request if none existed) 2. Attribute management Manage session attributes (get/set attributes associated to that session) 3. Session tracking Ensure that the client knows the session identifier so that later requests from the same client may be associated (by the server) to the same session 4. Session destruction 18

Sessions. Servlet and JSP API Session creation/identification A client wants to interact with a server (e.g., the client wants to make a reservation in an theatre reservation web application). The client requires session management When the client calls the first servlet/jsp page of the application, the server must create the session. When the client calls a posterior servlet/jsp page (after the session creation), the server must retrieve the session that was created previously. This session is attached to the client request by means of a cookie (or a parameter in the query string) that contains the session identifier How is this done? In the following slides we will see it both for servlets and JSP pages 19

Sessions. Servlet and JSP API Session creation/identification. Servlets The method service(request, response)/doget(request, response)/dopost(request, response) should incorporate the following sentence: HttpSession session=request.getsession(); Creates a session (with a new identifier) if request does not contain any session identifier. Otherwise, it retrieves the session identifier attached to request (by means of a cookie or a parameter in a query string) and uses it to build an object of class HttpSession HttpSession session=request.getsession(create); If create=true, the same as before If create=false, retrieves an already existing session but it does not create a new one if request does not have any session identifier attached to 20

Sessions. Servlet and JSP API Session creation/identification. JSP pages JSP pages that need session management should use the page directive <%@ page session="true" %> If this directive is used, then A JSP page can refer to the session which is associated to it by means of the implicit variable session In the following slides we explain how this is possible... 21

Sessions. Servlet and JSP API Session creation/identification. JSP pages (2) (Some aspects of the JSP to servlet translation) JSP pages are automatically translated into a servlet. This translation consists of the following issues: Creation of a context for the JSP page This context includes session management Request management and response creation This management includes the get/set of session attributes The next slides focus on the creation of a context for a JSP page 22

Sessions. Servlet and JSP API Session creation/identification. JSP pages (3) (Some aspects of the JSP to servlet translation) This is a fragment of the automatic translation of a JSP page into a servlet that ilustrates how the context of a JSP page is created: public void _jspservice(httpservletrequest request, HttpServletResponse response) throws java.io.ioexception, ServletException { //Variable declaration... try { jspxfactory = JspFactory.getDefaultFactory(); pagecontext = jspxfactory.getpagecontext(this, request,response, null, true, 8192, true); application = pagecontext.getservletcontext(); config = pagecontext.getservletconfig(); session = pagecontext.getsession(); out = pagecontext.getout(); //... Request management and response creation... } catch (Throwable t) { //... } finally { if (jspxfactory!= null) jspxfactory.releasepagecontext(pagecontext); } } 23

Sessions. Servlet and JSP API Session creation/identification. JSP pages (4) (Some aspects of the JSP to servlet translation) JspFactory jspf = JspFactory.getDefaultFactory(); PageContext pagecontext = jspf.getpagecontext(this, request, response, null, true, 8192, true); pagecontext is an object that encapsulates the page context, which includes the following aspects associated to the JSP page: The request that has launched this JSP page That is, the first parameter of retrieved by: jspservice. It can be request=pagecontext.getrequest(); The pending response which will be generated as a result of the execution of this JSP page and, afterwards, sent to the client response=pagecontext.getresponse(); 24

Sessions. Servlet and JSP API The output stream that has been associated to this JSP page out=pagecontext.getout(); The session that is associated to this request getpagecontext(...) calls request.getsession() The session can be retrieved by: session = pagecontext.getsession(); The application to which this JSP page is associated (useful to define application objects. See below) application = pagecontext.getservletcontext(); 25

Sessions. Servlet and JSP API Session creation/identification. JSP pages (5) (Some aspects of the JSP to servlet translation) As a consequence of this translation, in the JSP page the following implicit variables are available (no need to declare or initialize them): request response out pagecontext session application config page exception Therefore the JSP page can refer to the session which has been associated to it by means of the implicit variable session. 26

Sessions. Servlet and JSP API Attribute management Servlets and JSP pages may remember several objects across different requests within the same session Remembering an object This is done by associating the object which is to be remembered to an attribute name (a key string) In turn, this attribute name will be associated to the session ObjectClass object=new Object(...); session.setattribute("attrname", object);} Retrieving the object Another request associated to the same session may retrieve the object associated to the attribute called attrname in the following way: ObjectClass oc= (ObjectClass) session.getattribute("attrname"); 27

Sessions. Servlet and JSP API Attribute management (2) Some considerations: Only objects can be stored as attributes Primitive types (e.g., int, float...) must be wrapped using the wrapper classes (e.g., Integer, Float...) Different servlets/jsp pages share the same session attributes. Beware of name clash. 28

Sessions. Servlet and JSP API Session tracking In order to identify and manage the session associated to a request: The server should send the session identifier to the client in its response The client should send the session identifier (obtained from the server) in subsequent requests This can be done in two different ways: 1. By means of a cookie 2. By adding the session identifier in the query string of the request 29

Sessions. Servlet and JSP API Session tracking. Cookies When a servlet creates a session by means of getsession() or getsession(true) it adds a cookie to the response to be sent to the client In particular, it adds a header to the response with the following code: Set-Cookie: JSESSIONID=123456789poiuyt When the client sends subsequent requests to the server, it adds to the request the previous cookie: Cookie: JSESSIONID=123456789poiuyt When the servlet executes the operation request.getsession() for a request that contains a cookie JSESSIONID=sessionId, it returns a session with the identifier sessionid 30

Sessions. Servlet and JSP API Session tracking. Query string The client may not accept cookies. However, session management should be equally possible, even in this case Idea: If the client does not accept cookies, include the session identifier as a parameter of any subsequent request sent by the client The parameter will be codified as a query string accompanying the URL of the request Example: <a href="counter.jsp;jsessionid=9898988787xcds8"> link </a> How can we do this?... 31

Sessions. Servlet and JSP API Session tracking. Query string How can we do this? The HttpServletResponse interface provides the method: java.lang.string encodeurl(java.lang.string url) This method encodes the url by including the session identifier only in the case that this is necessary (client browser does not accept cookies and the servlet requires session management). It returns the encoded url or the url unchanged (if encoding is not necessary) 32

Sessions. Servlet and JSP API Session tracking. Query string Example in a JSP page: <a href="<%=response.encodeurl("counter.jsp") %>"> link </a> The client will receive: If it does not accept cookies and session management is enabled for that JSP page: <a href="http://ingrid.udl.net:8080/counter.jsp? jsessionid=9898988787xcds8"> link </a> If it accepts cookies and session management is enabled for that JSP page: <a href="http://ingrid.udl.net:8080/counter.jsp"> link </a> 33

Sessions. Servlet and JSP API Session destruction Sessions are automatically cancelled (and their resources deallocated) when they reach a certain timeout This timeout is specified in the configuration file web.xml of the server container. In the case of Tomcat: <web-app>... <session-config> <session-timeout> 30 </session-timeout> </session-config>... </web-app> In this case, the session timeout is established in 30 minutes It is possible to change the timeout for a specific session using the method setmaxinactiveinterval(n) of the interface HttpSession: session.setmaxinactiveinterval(300); This states the timeout for this session to 300 seconds (5 minutes). 34

Sessions. Servlet and JSP API Session destruction Sessions can be explicitly cancelled by using the method invalidate(): session.invalidate(); 35

Sessions. Servlet and JSP API. Example 1 Example 1: A JSP page to count page accesses Example location: sessions/examples/ex4 <%@ page session="true" %> <html> <h2> Access counter with session support</h2> <p> This version relies on cookies. If cookies are disabled in the client, this does not work <% if (session.getattribute("counter")==null) session.setattribute("counter", new Integer(1)); int c=((integer) session.getattribute("counter")).intvalue(); %> This is your access number <%=c%> <% session.setattribute("counter",new Integer(c+1)); %> <p> Click <a href="index.jsp"> here </a> </html> Warning: This example only works if the cookies are enabled in the client 36

Sessions. Servlet and JSP API. Example 1 Ex. 1: A JSP page to count page accesses Example location: sessions/examples/ex5 <%@ page session="true" %> <html> <h2> Access counter with session support</h2> <b>this version does not need cookies to work</b> <% if (session.getattribute("counter")==null) session.setattribute("counter", new Integer(1)); int c=((integer) session.getattribute("counter")).intvalue(); %> This is your access number <%=c%> <% session.setattribute("counter",new Integer(c+1)); %> <p> Click <a href="<%=response.encodeurl("index.jsp") %>"> here </a> </html> This version works both if the client has the cookies enabled or disabled Notice the use of: <%=response.encodeurl("index.jsp") %> 37

Sessions. Servlet and JSP API. Example 2 Example 2: A servlet to count page accesses Example location: sessions/examples/ex6 import javax.servlet.*; import java.io.*; import javax.servlet.http.*; import java.util.*; public class Counter extends HttpServlet { public void doget(httpservletrequest request, HttpServletResponse response) throws IOException, ServletException { dopost( request, response ) ; } continues... 38

Sessions. Servlet and JSP API. Example 2...continues public void dopost (HttpServletRequest request, HttpServletResponse response) { try { response.setcontenttype ("text/html;charset=iso-8859-1"); PrintWriter out = response.getwriter(); HttpSession session=request.getsession(); //getsession is responsible for including the cookie //JSESSIONID to the response if (session.getattribute("counter")==null) session.setattribute("counter", new Integer(1)); continues... int c= ((Integer) session.getattribute("counter")).intvalue(); 39

Sessions. Servlet and JSP API. Example 2 Example 2: A servlet to count page accesses...continues out.write("\n\n"); out.write("<html>\n\n"); out.write("<h2> Access counter"); out.write("</h2>\n\n"); out.write(" \n\nthis is your access number "); out.print(c); out.write("\n\n"); session.setattribute("counter",new Integer(c+1)); out.write("\n"); out.write("<p>\nclick \n\n\n"); out.write( "<a href=\"" + "counter\">"+ "here "); out.write("</a>\n\n"); out.write("</html>\n"); if (c>=5) session.invalidate(); } } } catch (Exception ex) { ex.printstacktrace(); } 40

Sessions. Servlet and JSP API. Example 3 Example 3: A shopping cart This example shows a primitive bookstore on-line It uses java beans, session management and JDBC. It is presented in java beans module (ex. ***) 41

Sessions. Scopes within a web application Scopes within a web application In JSP pages and servlets it is possible to define 4 different scopes for objects (attributes): Page scope Request scope Session scope Application scope 42

Sessions. Scopes within a web application Page scope An object (attribute) associated to a page scope is visible only within the JSP page to which that scope refers The page scope corresponds to the execution of the method jspservice of the servlet to which that JSP page is translated Object declaration within the page scope pagecontext.setattribute ("attrid",object,pagecontext.page_scope); pagecontext.setattribute("attrid",object); Recall that pagecontext is an implicit object that can be used in a JSP page 43

Sessions. Scopes within a web application Request scope An object (attribute) associated to a request scope is visible: Within the JSP page to which that http request refers and Within the pages invoked by means of <jsp:include..> or <jsp:forward...> from that page Object declaration within the request scope pagecontext.setattribute ("attrid",object,pagecontext.request_scope); request.setattribute("attrid",object); Recall that both pagecontext and request are implicit objects that can be used in a JSP page 44

Sessions. Scopes within a web application Session scope An object (attribute) associated to a session scope is visible within all the requests associated with an HttpSession object with a specific session ID Object declaration within the request scope pagecontext.setattribute ("attrid",object,pagecontext.session_scope); session.setattribute("attrid",object); Recall that both pagecontext and session are implicit objects that can be used in a JSP page The session scope is used normally when the following situation occurs: The application maintains a dialogue with the user through different http requests and Subsequent requests within the dialogue should remember the state of some application objects stated by previous requests 45

Sessions. Scopes within a web application Application scope An object (attribute) associated to an application scope is visible within all the servlets and JSP pages of an application Object declaration within the request scope pagecontext.setattribute ("attrid",object,pagecontext.application_scope); application.setattribute("attrid",object); Recall that both pagecontext and application are implicit objects that can be used in a JSP page 46

Sessions. Scopes within a web application Initialization parameters of the application scope It is possible to declare and initialize some constant parameters which should be visible throughout the application This initialization is done in the web.xml deployment descriptor: <context-param> <param-name>jdbc.driver</param-name> <param-value>jdbc.postgresql</param-value> </context-param> <context-param> <param-name>...</param-name> <param-value>...</param-value> </context-param>... This parameters can be retrieved within a JSP page/servlet: String driver= application.getinitparameter("jdbc.driver"); 47