FileDocCategorySizeDatePackage
Config.javaAPI DocGlassfish v2 API15119Sat May 05 19:17:14 BST 2007javax.servlet.jsp.jstl.core

Config

public class Config extends Object
Class supporting access to configuration settings.

Fields Summary
public static final String
FMT_LOCALE
Name of configuration setting for application- (as opposed to browser-) based preferred locale
public static final String
FMT_FALLBACK_LOCALE
Name of configuration setting for fallback locale
public static final String
FMT_LOCALIZATION_CONTEXT
Name of configuration setting for i18n localization context
public static final String
FMT_TIME_ZONE
Name of localization setting for time zone
public static final String
SQL_DATA_SOURCE
Name of configuration setting for SQL data source
public static final String
SQL_MAX_ROWS
Name of configuration setting for maximum number of rows to be included in SQL query result
private static final String
PAGE_SCOPE_SUFFIX
private static final String
REQUEST_SCOPE_SUFFIX
private static final String
SESSION_SCOPE_SUFFIX
private static final String
APPLICATION_SCOPE_SUFFIX
Constructors Summary
Methods Summary
public static java.lang.Objectfind(javax.servlet.jsp.PageContext pc, java.lang.String name)
Finds the value associated with a specific configuration setting identified by its context initialization parameter name.

For each of the JSP scopes (page, request, session, application), get the value of the configuration variable identified by name using method get(). Return as soon as a non-null value is found. If no value is found, get the value of the context initialization parameter identified by name.

param
pc Page context in which the configuration setting is to be searched
param
name Context initialization parameter name of the configuration setting
return
The java.lang.Object associated with the configuration setting identified by name, or null if it is not defined.

	Object ret = get(pc, name, PageContext.PAGE_SCOPE);
	if (ret == null) {
	    ret = get(pc, name, PageContext.REQUEST_SCOPE);
	    if (ret == null) {
		if (pc.getSession() != null) {
		    // check session only if a session is present
		    ret = get(pc, name, PageContext.SESSION_SCOPE);
		}
		if (ret == null) {
		    ret = get(pc, name, PageContext.APPLICATION_SCOPE);
		    if (ret == null) {
			ret = pc.getServletContext().getInitParameter(name);
		    }
		}
	    }
	}

	return ret;
    
public static java.lang.Objectget(javax.servlet.jsp.PageContext pc, java.lang.String name, int scope)
Looks up a configuration variable in the given scope.

The lookup of configuration variables is performed as if each scope had its own name space, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
pc Page context in which the configuration variable is to be looked up
param
name Configuration variable name
param
scope Scope in which the configuration variable is to be looked up
return
The java.lang.Object associated with the configuration variable, or null if it is not defined.


                                                                                                     
             
	switch (scope) {
	case PageContext.PAGE_SCOPE:
	    return pc.getAttribute(name + PAGE_SCOPE_SUFFIX, scope);
	case PageContext.REQUEST_SCOPE:
	    return pc.getAttribute(name + REQUEST_SCOPE_SUFFIX, scope);
	case PageContext.SESSION_SCOPE:
	    return get(pc.getSession(), name);
	case PageContext.APPLICATION_SCOPE:
	    return pc.getAttribute(name + APPLICATION_SCOPE_SUFFIX, scope);
	default:
	    throw new IllegalArgumentException("unknown scope");
	}
    
public static java.lang.Objectget(javax.servlet.ServletRequest request, java.lang.String name)
Looks up a configuration variable in the "request" scope.

The lookup of configuration variables is performed as if each scope had its own name space, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
request Request object in which the configuration variable is to be looked up
param
name Configuration variable name
return
The java.lang.Object associated with the configuration variable, or null if it is not defined.

	return request.getAttribute(name + REQUEST_SCOPE_SUFFIX);
    
public static java.lang.Objectget(javax.servlet.http.HttpSession session, java.lang.String name)
Looks up a configuration variable in the "session" scope.

The lookup of configuration variables is performed as if each scope had its own name space, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
session Session object in which the configuration variable is to be looked up
param
name Configuration variable name
return
The java.lang.Object associated with the configuration variable, or null if it is not defined, if session is null, or if the session is invalidated.

        Object ret = null;
        if (session != null) {
            try {
                ret = session.getAttribute(name + SESSION_SCOPE_SUFFIX);
            } catch (IllegalStateException ex) {} // when session is invalidated
        }
        return ret;
    
public static java.lang.Objectget(javax.servlet.ServletContext context, java.lang.String name)
Looks up a configuration variable in the "application" scope.

The lookup of configuration variables is performed as if each scope had its own name space, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
context Servlet context in which the configuration variable is to be looked up
param
name Configuration variable name
return
The java.lang.Object associated with the configuration variable, or null if it is not defined.

	return context.getAttribute(name + APPLICATION_SCOPE_SUFFIX);
    
public static voidremove(javax.servlet.ServletRequest request, java.lang.String name)
Removes a configuration variable from the "request" scope.

Removing a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not impact one stored in a different scope.

param
request Request object from which the configuration variable is to be removed
param
name Configuration variable name

	request.removeAttribute(name + REQUEST_SCOPE_SUFFIX);
    
public static voidremove(javax.servlet.http.HttpSession session, java.lang.String name)
Removes a configuration variable from the "session" scope.

Removing a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not impact one stored in a different scope.

param
session Session object from which the configuration variable is to be removed
param
name Configuration variable name

	session.removeAttribute(name + SESSION_SCOPE_SUFFIX);
    
public static voidremove(javax.servlet.ServletContext context, java.lang.String name)
Removes a configuration variable from the "application" scope.

Removing a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not impact one stored in a different scope.

param
context Servlet context from which the configuration variable is to be removed
param
name Configuration variable name

	context.removeAttribute(name + APPLICATION_SCOPE_SUFFIX);
    
public static voidremove(javax.servlet.jsp.PageContext pc, java.lang.String name, int scope)
Removes a configuration variable from the given scope.

Removing a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not impact one stored in a different scope.

param
pc Page context from which the configuration variable is to be removed
param
name Configuration variable name
param
scope Scope from which the configuration variable is to be removed

	switch (scope) {
	case PageContext.PAGE_SCOPE:
	    pc.removeAttribute(name + PAGE_SCOPE_SUFFIX, scope);
	    break;
	case PageContext.REQUEST_SCOPE:
	    pc.removeAttribute(name + REQUEST_SCOPE_SUFFIX, scope);
	    break;
	case PageContext.SESSION_SCOPE:
	    pc.removeAttribute(name + SESSION_SCOPE_SUFFIX, scope);
	    break;
	case PageContext.APPLICATION_SCOPE:
	    pc.removeAttribute(name + APPLICATION_SCOPE_SUFFIX, scope);
	    break;
	default:
	    throw new IllegalArgumentException("unknown scope");
	}
    
public static voidset(javax.servlet.jsp.PageContext pc, java.lang.String name, java.lang.Object value, int scope)
Sets the value of a configuration variable in the given scope.

Setting the value of a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
pc Page context in which the configuration variable is to be set
param
name Configuration variable name
param
value Configuration variable value
param
scope Scope in which the configuration variable is to be set

	switch (scope) {
	case PageContext.PAGE_SCOPE:
	    pc.setAttribute(name + PAGE_SCOPE_SUFFIX, value, scope);
	    break;
	case PageContext.REQUEST_SCOPE:
	    pc.setAttribute(name + REQUEST_SCOPE_SUFFIX, value, scope);
	    break;
	case PageContext.SESSION_SCOPE:
	    pc.setAttribute(name + SESSION_SCOPE_SUFFIX, value, scope);
	    break;
	case PageContext.APPLICATION_SCOPE:
	    pc.setAttribute(name + APPLICATION_SCOPE_SUFFIX, value, scope);
	    break;
	default:
	    throw new IllegalArgumentException("unknown scope");
	}
    
public static voidset(javax.servlet.ServletRequest request, java.lang.String name, java.lang.Object value)
Sets the value of a configuration variable in the "request" scope.

Setting the value of a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
request Request object in which the configuration variable is to be set
param
name Configuration variable name
param
value Configuration variable value

	request.setAttribute(name + REQUEST_SCOPE_SUFFIX, value);
    
public static voidset(javax.servlet.http.HttpSession session, java.lang.String name, java.lang.Object value)
Sets the value of a configuration variable in the "session" scope.

Setting the value of a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
session Session object in which the configuration variable is to be set
param
name Configuration variable name
param
value Configuration variable value

	session.setAttribute(name + SESSION_SCOPE_SUFFIX, value);
    
public static voidset(javax.servlet.ServletContext context, java.lang.String name, java.lang.Object value)
Sets the value of a configuration variable in the "application" scope.

Setting the value of a configuration variable is performed as if each scope had its own namespace, that is, the same configuration variable name in one scope does not replace one stored in a different scope.

param
context Servlet context in which the configuration variable is to be set
param
name Configuration variable name
param
value Configuration variable value

	context.setAttribute(name + APPLICATION_SCOPE_SUFFIX, value);