|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
javax.faces.context Class ExternalContext
java.lang.Object javax.faces.context.ExternalContext
public abstract class ExternalContext
- extends Object
This class allows the Faces API to be unaware of the nature of its containing application environment. In particular, this class allows JavaServer Faces based appications to run in either a Servlet or a Portlet environment.
In the method descriptions below, paragraphs starting with Servlet: and Portlet: denote behavior that is specific to that particular environment.
字段摘要 | |
---|---|
static String |
BASIC_AUTH
String identifier for BASIC authentication. |
static String |
CLIENT_CERT_AUTH
String identifier for CLIENT_CERT authentication. |
static String |
DIGEST_AUTH
String identifier for DIGEST authentication. |
static String |
FORM_AUTH
String identifier for FORM authentication. |
构造器摘要 | |
---|---|
ExternalContext()
|
方法摘要 | |
---|---|
abstract void |
dispatch(String path)
Dispatch a request to the specified resource to create output for this response. |
abstract String |
encodeActionURL(String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable action in the current application. |
abstract String |
encodeNamespace(String name)
Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page. |
abstract String |
encodeResourceURL(String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application. |
abstract Map<String,Object> |
getApplicationMap()
Return a mutable Map representing the application
scope attributes for the current application. |
abstract String |
getAuthType()
Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, return null . |
abstract Object |
getContext()
Return the application environment object instance for the current appication. |
abstract String |
getInitParameter(String name)
Return the value of the specified application initialization parameter (if any). |
abstract Map |
getInitParameterMap()
Return an immutable Map whose keys are the set of
application initialization parameter names configured for this
application, and whose values are the corresponding parameter
values. |
abstract String |
getRemoteUser()
Return the login name of the user making the current request if any; otherwise, return null . |
abstract Object |
getRequest()
Return the environment-specific object instance for the current request. |
String |
getRequestCharacterEncoding()
Return the character encoding currently being used to interpret this request. |
String |
getRequestContentType()
Return the MIME Content-Type for this request. |
abstract String |
getRequestContextPath()
Return the portion of the request URI that identifies the web application context for this request. |
abstract Map<String,Object> |
getRequestCookieMap()
Return an immutable Map whose keys are the set of
cookie names included in the current request, and whose
values (of type javax.servlet.http.Cookie )
are the first (or only) cookie for each cookie name
returned by the underlying request. |
abstract Map<String,String> |
getRequestHeaderMap()
Return an immutable Map whose keys are the set of
request header names included in the current request, and whose
values (of type String) are the first (or only) value for each
header name returned by the underlying request. |
abstract Map<String,String[]> |
getRequestHeaderValuesMap()
Return an immutable Map whose keys are the set of
request header names included in the current request, and whose
values (of type String[]) are all of the value for each
header name returned by the underlying request. |
abstract Locale |
getRequestLocale()
Return the preferred Locale in which the client
will accept content. |
abstract Iterator<Locale> |
getRequestLocales()
Return an Iterator over the preferred
Locale s specified in the request, in decreasing
order of preference. |
abstract Map<String,Object> |
getRequestMap()
Return a mutable Map representing the request
scope attributes for the current application. |
abstract Map<String,String> |
getRequestParameterMap()
Return an immutable Map whose keys are the set of
request parameters names included in the current request, and whose
values (of type String) are the first (or only) value for each
parameter name returned by the underlying request. |
abstract Iterator<String> |
getRequestParameterNames()
Return an Iterator over the names of all request
parameters included in the current request. |
abstract Map<String,String[]> |
getRequestParameterValuesMap()
Return an immutable Map whose keys are the set of
request parameters names included in the current request, and whose
values (of type String[]) are all of the values for each
parameter name returned by the underlying request. |
abstract String |
getRequestPathInfo()
Return the extra path information (if any) included in the request URI; otherwise, return null . |
abstract String |
getRequestServletPath()
Return the servlet path information (if any) included in the request URI; otherwise, return null . |
abstract URL |
getResource(String path)
Return a URL for the application resource mapped to the
specified path, if it exists; otherwise, return null . |
abstract InputStream |
getResourceAsStream(String path)
Return an InputStream for an application resource
mapped to the specified path, if it exists; otherwise, return
null . |
abstract Set<String> |
getResourcePaths(String path)
Return the Set of resource paths for all application
resources whose resource path starts with the specified argument. |
abstract Object |
getResponse()
Return the environment-specific object instance for the current response. |
String |
getResponseCharacterEncoding()
Returns the name of the character encoding (MIME charset) used for the body sent in this response. |
String |
getResponseContentType()
Return the MIME Content-Type for this response. |
abstract Object |
getSession(boolean create)
If the create parameter is true ,
create (if necessary) and return a session instance associated
with the current request. |
abstract Map<String,Object> |
getSessionMap()
Return a mutable Map representing the session
scope attributes for the current application. |
abstract Principal |
getUserPrincipal()
Return the Principal object containing the name of
the current authenticated user, if any; otherwise, return
null . |
abstract boolean |
isUserInRole(String role)
Return true if the currently authenticated user is
included in the specified role. |
abstract void |
log(String message)
Log the specified message to the application object. |
abstract void |
log(String message,
Throwable exception)
Log the specified message and exception to the application object. |
abstract void |
redirect(String url)
Redirect a request to the specified URL, and cause the responseComplete() method to be called on the
FacesContext instance for the current request. |
void |
setRequest(Object request)
Set the environment-specific request to be returned by subsequent calls to getRequest() . |
void |
setRequestCharacterEncoding(String encoding)
Overrides the name of the character encoding used in the body of this request. |
void |
setResponse(Object response)
Set the environment-specific response to be returned by subsequent calls to getResponse() . |
void |
setResponseCharacterEncoding(String encoding)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. |
类方法继承 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段详细信息 |
---|
BASIC_AUTH
public static final String BASIC_AUTH
String identifier for BASIC authentication.
- 另请参见:
- 常量字段
CLIENT_CERT_AUTH
public static final String CLIENT_CERT_AUTH
String identifier for CLIENT_CERT authentication.
- 另请参见:
- 常量字段
DIGEST_AUTH
public static final String DIGEST_AUTH
String identifier for DIGEST authentication.
- 另请参见:
- 常量字段
FORM_AUTH
public static final String FORM_AUTH
String identifier for FORM authentication.
- 另请参见:
- 常量字段
构造器详细信息 |
---|
ExternalContext
public ExternalContext()
方法详细信息 |
---|
dispatch
public abstract void dispatch(String path) throws IOException
Dispatch a request to the specified resource to create output for this response.
Servlet: This must be accomplished by calling the
javax.servlet.ServletContext
methodgetRequestDispatcher(path)
, and calling theforward()
method on the resulting object.Portlet: This must be accomplished by calling the
javax.portlet.PortletContext
methodgetRequestDispatcher()
, and calling theinclude()
method on the resulting object.- 参数:
path
- Context relative path to the specified resource, which must start with a slash ("/") character- 抛出异常:
FacesException
- thrown if aServletException
orPortletException
occursIllegalArgumentException
- if no request dispatcher can be created for the specified pathIllegalStateException
- if this method is called in a portlet environment, and the current request is anActionRequest
instead of aRenderRequest
IOException
- if an input/output error occursNullPointerException
- ifpath
isnull
encodeActionURL
public abstract String encodeActionURL(String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable action in the current application.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletResponse
methodencodeURL(url)
.Portlet: This must be the value returned by the
javax.portlet.PortletResponse
methodencodeURL(url)
.- 参数:
url
- The input URL to be encoded- 抛出异常:
NullPointerException
- ifurl
isnull
encodeNamespace
public abstract String encodeNamespace(String name)
Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.
Servlet: The input value must be returned unchanged.
Portlet: The returned value must be the input value prefixed by the value returned by the
javax.portlet.RenderResponse
methodgetNamespace()
.- 参数:
name
- Name to be encoded- 抛出异常:
IllegalStateException
- if this method is called in a portlet environment, and the current response is anActionResponse
instead of aRenderResponse
NullPointerException
- ifname
isnull
encodeResourceURL
public abstract String encodeResourceURL(String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletResponse
methodencodeURL(url)
.Portlet: This must be the value returned by the
javax.portlet.PortletResponse
methodencodeURL(url)
.- 参数:
url
- The input URL to be encoded- 抛出异常:
NullPointerException
- ifurl
isnull
getApplicationMap
public abstract Map<String,Object> getApplicationMap()
Return a mutable
Map
representing the application scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must cause the corresponding changes in the set of application scope attributes. Particularly theclear()
,remove()
,put()
,putAll()
, andget()
operations must take the appropriate action on the underlying data structure.For any of the
Map
methods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy
, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroy
annotated methods must by caught and not rethrown. The exception may be logged.Servlet: This must be the set of attributes available via the
javax.servlet.ServletContext
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.Portlet: This must be the set of attributes available via the
javax.portlet.PortletContext
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.
getAuthType
public abstract String getAuthType()
Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, return
null
. For standard authentication schemes, the returned value will match one of the following constants:BASIC_AUTH
,CLIENT_CERT_AUTH
,DIGEST_AUTH
, orFORM_AUTH
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetAuthType()
.Portlet: This must be the value returned by the
javax.portlet.http.PortletRequest
methodgetAuthType()
.
getContext
public abstract Object getContext()
Return the application environment object instance for the current appication.
Servlet: This must be the current application's
javax.servlet.ServletContext
instance.Portlet: This must be the current application's
javax.portlet.PortletContext
instance.
getInitParameter
public abstract String getInitParameter(String name)
Return the value of the specified application initialization parameter (if any).
Servlet: This must be the result of the
javax.servlet.ServletContext
methodgetInitParameter(name)
.Portlet: This must be the result of the
javax.portlet.PortletContext
methodgetInitParameter(name)
.- 参数:
name
- Name of the requested initialization parameter- 抛出异常:
NullPointerException
- ifname
isnull
getInitParameterMap
public abstract Map getInitParameterMap()
Return an immutable
Map
whose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Servlet: This result must be as if it were synthesized by calling the
javax.servlet.ServletContext
methodgetInitParameterNames
, and putting each configured parameter name/value pair into the result.Portlet: This result must be as if it were synthesized by calling the
javax.portlet.PortletContext
methodgetInitParameterNames
, and putting each configured parameter name/value pair into the result.
getRemoteUser
public abstract String getRemoteUser()
Return the login name of the user making the current request if any; otherwise, return
null
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetRemoteUser()
.Portlet: This must be the value returned by the
javax.portlet.http.PortletRequest
methodgetRemoteUser()
.
getRequest
public abstract Object getRequest()
Return the environment-specific object instance for the current request.
Servlet: This must be the current request's
javax.servlet.http.HttpServletRequest
instance.Portlet: This must be the current request's
javax.portlet.PortletRequest
instance, which will be either anActionRequest
or aRenderRequest
depending upon when this method is called.
setRequest
public void setRequest(Object request)
Set the environment-specific request to be returned by subsequent calls to
getRequest()
. This may be used to install a wrapper for the request.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
setRequestCharacterEncoding
public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException
Overrides the name of the character encoding used in the body of this request.
Calling this method after the request has been accessed will have no no effect, unless a
Reader
orStream
has been obtained from the request, in which case anIllegalStateException
is thrown.Servlet: This must call through to the
javax.servlet.ServletRequest
methodsetCharacterEncoding()
.Portlet: This must call through to the
javax.portlet.ActionRequest
methodsetCharacterEncoding()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 抛出异常:
UnsupportedEncodingException
- if this is not a valid encoding- 从以下版本开始:
- 1.2
getRequestContextPath
public abstract String getRequestContextPath()
Return the portion of the request URI that identifies the web application context for this request.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetContextPath()
.Portlet: This must be the value returned by the
javax.portlet.PortletRequest
methodgetContextPath()
.
getRequestCookieMap
public abstract Map<String,Object> getRequestCookieMap()
Return an immutable
Map
whose keys are the set of cookie names included in the current request, and whose values (of typejavax.servlet.http.Cookie
) are the first (or only) cookie for each cookie name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetCookies()
, unlessnull
was returned, in which case this must be a zero-length array.Portlet: Ths must be an empty Map.
getRequestHeaderMap
public abstract Map<String,String> getRequestHeaderMap()
Return an immutable
Map
whose keys are the set of request header names included in the current request, and whose values (of type String) are the first (or only) value for each header name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
. In addition, key comparisons must be performed in a case insensitive manner.Servlet: This must be the set of headers available via the
javax.servlet.http.HttpServletRequest
methodsgetHeader()
andgetHeaderNames()
.Portlet: This must be the set of properties available via the
javax.portlet.PortletRequest
methodsgetProperty()
andgetPropertyNames()
. As such, HTTP headers will only be included if they were provided by the portlet container, and additional properties provided by the portlet container may also be included.
getRequestHeaderValuesMap
public abstract Map<String,String[]> getRequestHeaderValuesMap()
Return an immutable
Map
whose keys are the set of request header names included in the current request, and whose values (of type String[]) are all of the value for each header name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
. In addition, key comparisons must be performed in a case insensitive manner.Servlet: This must be the set of headers available via the
javax.servlet.http.HttpServletRequest
methodsgetHeaders()
andgetHeaderNames()
.Portlet: This must be the set of properties available via the
javax.portlet.PortletRequest
methodsgetProperties()
andgetPropertyNames()
. As such, HTTP headers will only be included if they were provided by the portlet container, and additional properties provided by the portlet container may also be included.
getRequestLocale
public abstract Locale getRequestLocale()
Return the preferred
Locale
in which the client will accept content.Servlet: This must be the value returned by the
javax.servlet.ServletRequest
methodgetLocale()
.Portlet: This must be the value returned by the
javax.portlet.PortletRequest
methodgetLocale()
.
getRequestLocales
public abstract Iterator<Locale> getRequestLocales()
Return an
Iterator
over the preferredLocale
s specified in the request, in decreasing order of preference.Servlet: This must be an
Iterator
over the values returned by thejavax.servlet.ServletRequest
methodgetLocales()
.Portlet: This must be an
Iterator
over the values returned by thejavax.portlet.PortletRequest
methodgetLocales()
.
getRequestMap
public abstract Map<String,Object> getRequestMap()
Return a mutable
Map
representing the request scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must cause the corresponding changes in the set of request scope attributes. Particularly theclear()
,remove()
,put()
,putAll()
, andget()
operations must take the appropriate action on the underlying data structure.For any of the
Map
methods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy
, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroy
annotated methods must by caught and not rethrown. The exception may be logged.Servlet: This must be the set of attributes available via the
javax.servlet.ServletRequest
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.Portlet: This must be the set of attributes available via the
javax.portlet.PortletRequest
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.
getRequestParameterMap
public abstract Map<String,String> getRequestParameterMap()
Return an immutable
Map
whose keys are the set of request parameters names included in the current request, and whose values (of type String) are the first (or only) value for each parameter name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequest
methodsgetParameter()
andgetParameterNames()
.Portlet: This must be the set of parameters available via the
javax.portlet.PortletRequest
methodsgetParameter()
andgetParameterNames()
.
getRequestParameterNames
public abstract Iterator<String> getRequestParameterNames()
Return an
Iterator
over the names of all request parameters included in the current request.Servlet: This must be an
Iterator
over the values returned by thejavax.servlet.ServletRequest
methodgetParameterNames()
.Portlet: This must be an
Iterator
over the values returned by thejavax.portlet.PortletRequest
methodgetParameterNames()
.
getRequestParameterValuesMap
public abstract Map<String,String[]> getRequestParameterValuesMap()
Return an immutable
Map
whose keys are the set of request parameters names included in the current request, and whose values (of type String[]) are all of the values for each parameter name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequest
methodsgetParameterValues()
andgetParameterNames()
.Portlet: This must be the set of parameters available via the
javax.portlet.PortletRequest
methodsgetParameterValues()
andgetParameterNames()
.
getRequestPathInfo
public abstract String getRequestPathInfo()
Return the extra path information (if any) included in the request URI; otherwise, return
null
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetPathInfo()
.Portlet: This must be
null
.
getRequestServletPath
public abstract String getRequestServletPath()
Return the servlet path information (if any) included in the request URI; otherwise, return
null
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetServletPath()
.Portlet: This must be
null
.
getRequestCharacterEncoding
public String getRequestCharacterEncoding()
Return the character encoding currently being used to interpret this request.
Servlet: This must return the value returned by the
javax.servlet.ServletRequest
methodgetCharacterEncoding()
.Portlet: This must return the value returned by the
javax.portlet.ActionRequest
methodgetCharacterEncoding()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
getRequestContentType
public String getRequestContentType()
Return the MIME Content-Type for this request. If not available, return
null
.Servlet: This must return the value returned by the
javax.servlet.ServletRequest
methodgetContentType()
.Portlet: This must return
null
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
getResponseCharacterEncoding
public String getResponseCharacterEncoding()
Returns the name of the character encoding (MIME charset) used for the body sent in this response.
Servlet: This must return the value returned by the
javax.servlet.ServletResponse
methodgetCharacterEncoding()
.Portlet: This must return
null
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
getResponseContentType
public String getResponseContentType()
Return the MIME Content-Type for this response. If not available, return
null
.Servlet: This must return the value returned by the
javax.servlet.ServletResponse
methodgetContentType()
.Portlet: This must return
null
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
getResource
public abstract URL getResource(String path) throws MalformedURLException
Return a
URL
for the application resource mapped to the specified path, if it exists; otherwise, returnnull
.Servlet: This must be the value returned by the
javax.servlet.ServletContext
methodgetResource(path)
.Portlet: This must be the value returned by the
javax.portlet.PortletContext
methodgetResource(path)
.- 参数:
path
- The path to the requested resource, which must start with a slash ("/" character- 抛出异常:
MalformedURLException
- if the specified path is not in the correct formNullPointerException
- ifpath
isnull
getResourceAsStream
public abstract InputStream getResourceAsStream(String path)
Return an
InputStream
for an application resource mapped to the specified path, if it exists; otherwise, returnnull
.Servlet: This must be the value returned by the
javax.servlet.ServletContext
methodgetResourceAsStream(path)
.Portlet: This must be the value returned by the
javax.portlet.PortletContext
methodgetResourceAsStream(path)
.- 参数:
path
- The path to the requested resource, which must start with a slash ("/" character- 抛出异常:
NullPointerException
- ifpath
isnull
getResourcePaths
public abstract Set<String> getResourcePaths(String path)
Return the
Set
of resource paths for all application resources whose resource path starts with the specified argument.Servlet: This must be the value returned by the
javax.servlet.ServletContext
methodgetResourcePaths(path).
Portlet: This must be the value returned by the
javax.portlet.PortletContext
methodgetResourcePaths(path).
- 参数:
path
- Partial path used to match resources, which must start with a slash ("/") character- 抛出异常:
NullPointerException
- ifpath
isnull
getResponse
public abstract Object getResponse()
Return the environment-specific object instance for the current response.
Servlet: This is the current request's
javax.servlet.http.HttpServletResponse
instance.Portlet: This is the current request's
javax.portlet.PortletResponse
instance, which will be either anActionResponse
or aRenderResponse
depending upon when this method is called.
setResponse
public void setResponse(Object response)
Set the environment-specific response to be returned by subsequent calls to
getResponse()
. This may be used to install a wrapper for the response.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
setResponseCharacterEncoding
public void setResponseCharacterEncoding(String encoding)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
Servlet: This must call through to the
javax.servlet.ServletResponse
methodsetCharacterEncoding()
.Portlet: This method must take no action.
The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- 从以下版本开始:
- 1.2
getSession
public abstract Object getSession(boolean create)
If the
create
parameter istrue
, create (if necessary) and return a session instance associated with the current request. If thecreate
parameter isfalse
return any existing session instance associated with the current request, or returnnull
if there is no such session.Servlet: This must return the result of calling
getSession(create)
on the underlyingjavax.servlet.http.HttpServletRequest
instance.em>Portlet: This must return the result of calling
getPortletSession(create)
on the underlyingjavax.portlet.PortletRequest
instance.- 参数:
create
- Flag indicating whether or not a new session should be created if there is no session associated with the current request
getSessionMap
public abstract Map<String,Object> getSessionMap()
Return a mutable
Map
representing the session scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must cause the corresponding changes in the set of session scope attributes. Particularly theclear()
,remove()
,put()
, andget()
operations must take the appropriate action on the underlying data structure. Accessing attributes via thisMap
must cause the creation of a session associated with the current request, if such a session does not already exist.For any of the
Map
methods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy
, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroy
annotated methods must by caught and not rethrown. The exception may be logged.Servlet: This must be the set of attributes available via the
javax.servlet.http.HttpServletSession
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.Portlet: This must be the set of attributes available via the
javax.portlet.PortletSession
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
. All session attribute access must occur in PORTLET_SCOPE scope within the session.
getUserPrincipal
public abstract Principal getUserPrincipal()
Return the
Principal
object containing the name of the current authenticated user, if any; otherwise, returnnull
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodgetUserPrincipal()
.Portlet: This must be the value returned by the
javax.portlet.http.PortletRequest
methodgetUserPrincipal()
.
isUserInRole
public abstract boolean isUserInRole(String role)
Return
true
if the currently authenticated user is included in the specified role. Otherwise, returnfalse
.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest
methodisUserInRole(role)
.Portlet: This must be the value returned by the
javax.portlet.http.PortletRequest
methodisUserInRole(role)
.- 参数:
role
- Logical role name to be checked- 抛出异常:
NullPointerException
- ifrole
isnull
log
public abstract void log(String message)
Log the specified message to the application object.
Servlet: This must be performed by calling the
javax.servlet.ServletContext
methodlog(String)
.Portlet: This must be performed by calling the
javax.portlet.PortletContext
methodlog(String)
.- 参数:
message
- Message to be logged- 抛出异常:
NullPointerException
- ifmessage
isnull
log
public abstract void log(String message, Throwable exception)
Log the specified message and exception to the application object.
Servlet: This must be performed by calling the
javax.servlet.ServletContext
methodlog(String,Throwable)
.Portlet: This must be performed by calling the
javax.portlet.PortletContext
methodlog(String,Throwable)
.- 参数:
message
- Message to be loggedexception
- Exception to be logged- 抛出异常:
NullPointerException
- ifmessage
orexception
isnull
redirect
public abstract void redirect(String url) throws IOException
Redirect a request to the specified URL, and cause the
responseComplete()
method to be called on theFacesContext
instance for the current request.Servlet: This must be accomplished by calling the
javax.servlet.http.HttpServletResponse
methodsendRedirect()
.Portlet: This must be accomplished by calling the
javax.portlet.ActionResponse
methodsendRedirect()
.- 参数:
url
- Absolute URL to which the client should be redirected- 抛出异常:
IllegalArgumentException
- if the specified url is relativeIllegalStateException
- if, in a portlet environment, the current response object is aRenderResponse
instead of anActionResponse
IllegalStateException
- if, in a servlet environment, the current response has already been committedIOException
- if an input/output error occurs
|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
提交错误或意见
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.