本文整理汇总了Java中javax.servlet.jsp.PageContext.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java PageContext.getAttribute方法的具体用法?Java PageContext.getAttribute怎么用?Java PageContext.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.jsp.PageContext
的用法示例。
在下文中一共展示了PageContext.getAttribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookup
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Locate and return the specified bean, from an optionally specified
* scope, in the specified page context. If no such bean is found,
* return <code>null</code> instead. If an exception is thrown, it will
* have already been saved via a call to <code>saveException()</code>.
*
* @param pageContext Page context to be searched
* @param name Name of the bean to be retrieved
* @param scopeName Scope to be searched (page, request, session, application)
* or <code>null</code> to use <code>findAttribute()</code> instead
* @return JavaBean in the specified page context
* @exception JspException if an invalid scope name
* is requested
*/
public Object lookup(PageContext pageContext, String name, String scopeName)
throws JspException {
if (scopeName == null) {
return pageContext.findAttribute(name);
}
try {
return pageContext.getAttribute(name, instance.getScope(scopeName));
} catch (JspException e) {
saveException(pageContext, e);
throw e;
}
}
示例2: get
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
public static ScopeManager get(PageContext page) {
ScopeManager mngr = (ScopeManager) page.getAttribute(MNGR_KEY);
if (mngr == null) {
mngr = new ScopeManager(page);
page.setAttribute(MNGR_KEY, mngr);
}
return mngr;
}
示例3: isXhtml
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Returns true if the custom tags are in XHTML mode.
*/
public boolean isXhtml(PageContext pageContext) {
String xhtml =
(String) pageContext.getAttribute(
Globals.XHTML_KEY,
PageContext.PAGE_SCOPE);
return "true".equalsIgnoreCase(xhtml);
}
示例4: isXhtml
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* <p>Returns true if the custom tags are in XHTML mode.</p>
*
* @since Struts 1.1
* @deprecated Use {@link org.apache.struts.taglib.TagUtils#isXhtml(PageContext)} instead.
* This will be removed after Struts 1.2.
*/
public static boolean isXhtml(PageContext pageContext) {
// :TODO: Remove after Struts 1.2
String xhtml =
(String) pageContext.getAttribute(
Globals.XHTML_KEY,
PageContext.PAGE_SCOPE);
return "true".equalsIgnoreCase(xhtml);
}
示例5: getAttribute
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Get object from requested context.
* Context can be 'component'.
* @param beanName Name of the bean to find.
* @param scope Search scope (see {@link PageContext}).
* @param pageContext Page context.
* @return requested bean or <code>null</code> if not found.
*/
public Object getAttribute(
String beanName,
int scope,
PageContext pageContext) {
if (scope == ComponentConstants.COMPONENT_SCOPE){
return getAttribute(beanName);
}
return pageContext.getAttribute(beanName, scope);
}
示例6: getImplicitObjects
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Finds the ImplicitObjects associated with the PageContext,
* creating it if it doesn't yet exist.
**/
public static ImplicitObjects getImplicitObjects (PageContext pContext)
{
ImplicitObjects objs =
(ImplicitObjects)
pContext.getAttribute (sAttributeName,
PageContext.PAGE_SCOPE);
if (objs == null) {
objs = new ImplicitObjects (pContext);
pContext.setAttribute (sAttributeName,
objs,
PageContext.PAGE_SCOPE);
}
return objs;
}
示例7: createPageScopeMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that "wraps" page-scoped attributes
**/
public static Map<String, Object> createPageScopeMap(PageContext pContext)
{
final PageContext context = pContext;
return new EnumeratedMap<String, Object> ()
{
public Enumeration<String> enumerateKeys ()
{
return context.getAttributeNamesInScope
(PageContext.PAGE_SCOPE);
}
public Object getValue (Object pKey)
{
if (pKey instanceof String) {
return context.getAttribute
((String) pKey,
PageContext.PAGE_SCOPE);
}
else {
return null;
}
}
public boolean isMutable ()
{
return true;
}
};
}
示例8: createRequestScopeMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that "wraps" request-scoped attributes
**/
public static Map<String, Object> createRequestScopeMap (PageContext pContext)
{
final PageContext context = pContext;
return new EnumeratedMap<String, Object> ()
{
public Enumeration<String> enumerateKeys ()
{
return context.getAttributeNamesInScope
(PageContext.REQUEST_SCOPE);
}
public Object getValue (Object pKey)
{
if (pKey instanceof String) {
return context.getAttribute
((String) pKey,
PageContext.REQUEST_SCOPE);
}
else {
return null;
}
}
public boolean isMutable ()
{
return true;
}
};
}
示例9: createApplicationScopeMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that "wraps" application-scoped attributes
**/
public static Map<String, Object> createApplicationScopeMap (PageContext pContext)
{
final PageContext context = pContext;
return new EnumeratedMap<String, Object> ()
{
public Enumeration<String> enumerateKeys ()
{
return context.getAttributeNamesInScope
(PageContext.APPLICATION_SCOPE);
}
public Object getValue (Object pKey)
{
if (pKey instanceof String) {
return context.getAttribute
((String) pKey,
PageContext.APPLICATION_SCOPE);
}
else {
return null;
}
}
public boolean isMutable ()
{
return true;
}
};
}
示例10: get
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
public static ScopeManager get(PageContext page) {
ScopeManager mngr = (ScopeManager) page.getAttribute(MNGR_KEY);
if (mngr == null) {
mngr = new ScopeManager(page);
page.setAttribute(MNGR_KEY, mngr);
}
return mngr;
}
示例11: getActionMappingURL
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Return the form action converted into a server-relative URL.
*/
public String getActionMappingURL(String action, String module, PageContext pageContext, boolean contextRelative) {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String contextPath = request.getContextPath();
StringBuffer value = new StringBuffer();
// Avoid setting two slashes at the beginning of an action:
// the length of contextPath should be more than 1
// in case of non-root context, otherwise length==1 (the slash)
if (contextPath.length() > 1) value.append(contextPath);
ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(module, request, pageContext.getServletContext());
if ((moduleConfig != null) && (!contextRelative)) {
value.append(moduleConfig.getPrefix());
}
// Use our servlet mapping, if one is specified
String servletMapping =
(String) pageContext.getAttribute(
Globals.SERVLET_KEY,
PageContext.APPLICATION_SCOPE);
if (servletMapping != null) {
String queryString = null;
int question = action.indexOf("?");
if (question >= 0) {
queryString = action.substring(question);
}
String actionMapping = getActionMappingName(action);
if (servletMapping.startsWith("*.")) {
value.append(actionMapping);
value.append(servletMapping.substring(1));
} else if (servletMapping.endsWith("/*")) {
value.append(
servletMapping.substring(0, servletMapping.length() - 2));
value.append(actionMapping);
} else if (servletMapping.equals("/")) {
value.append(actionMapping);
}
if (queryString != null) {
value.append(queryString);
}
}
// Otherwise, assume extension mapping is in use and extension is
// already included in the action property
else {
if (!action.startsWith("/")) {
value.append("/");
}
value.append(action);
}
return value.toString();
}
示例12: createSessionScopeMap
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
*
* Creates the Map that "wraps" session-scoped attributes
**/
public static Map<String, Object> createSessionScopeMap (PageContext pContext)
{
final PageContext context = pContext;
return new EnumeratedMap<String, Object> ()
{
public Enumeration<String> enumerateKeys ()
{
return context.getAttributeNamesInScope
(PageContext.SESSION_SCOPE);
}
public Object getValue (Object pKey)
{
if (pKey instanceof String) {
return context.getAttribute
((String) pKey,
PageContext.SESSION_SCOPE);
}
else {
return null;
}
}
public boolean isMutable ()
{
return true;
}
};
}
示例13: getAttribute
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* Get object from requested context. Return <code>null</code> if not found.
* Context can be "component" or normal JSP contexts.
* @param beanName Name of bean to retrieve.
* @param scope Scope from which bean must be retrieved.
* @param pageContext Current pageContext.
* @return Requested bean or <code>null</code> if not found.
*/
public static Object getAttribute(String beanName, int scope, PageContext pageContext) {
if (scope == ComponentConstants.COMPONENT_SCOPE) {
ComponentContext compContext = ComponentContext.getContext(pageContext.getRequest());
return compContext.getAttribute(beanName);
}
return pageContext.getAttribute(beanName, scope);
}
示例14: setValue
import javax.servlet.jsp.PageContext; //导入方法依赖的package包/类
/**
* If the base object is <code>null</code>, sets an existing scoped
* attribute to the new value, or creates a new scoped attribute if one
* does not exist by this name.
*
* <p>If the provided attribute name matches the key of an attribute
* in page scope, request scope, session scope, or application scope, the
* corresponding attribute value will be replaced by the provided value.
* Otherwise, a new page scope attribute will be created with the
* given name and value.</p>
*
* <p>The <code>propertyResolved</code> property of the
* <code>ELContext</code> object must be set to <code>true</code> by
* this resolver before returning if base is <code>null</code>. If
* this property is not <code>true</code> after this method is called,
* the caller should ignore the return value.</p>
*
* @param context The context of this evaluation.
* @param base Only <code>null</code> is handled by this resolver.
* Other values will result in an immediate return.
* @param property The name of the scoped attribute to set.
* @param val The value for the scoped attribute.
* @throws NullPointerException if context is <code>null</code>.
* @throws ELException if an exception was thrown while performing
* the property or variable resolution. The thrown exception
* must be included as the cause property of this exception, if
* available.
*/
public void setValue(ELContext context,
Object base,
Object property,
Object val) {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
if (property instanceof String) {
PageContext ctxt = (PageContext)
context.getContext(JspContext.class);
String attr = (String) property;
if (ctxt.getAttribute(attr, PageContext.REQUEST_SCOPE) != null)
ctxt.setAttribute(attr, val, PageContext.REQUEST_SCOPE);
else if (ctxt.getAttribute(attr, PageContext.SESSION_SCOPE) != null)
ctxt.setAttribute(attr, val, PageContext.SESSION_SCOPE);
else if (ctxt.getAttribute(attr, PageContext.APPLICATION_SCOPE) != null)
ctxt.setAttribute(attr, val, PageContext.APPLICATION_SCOPE);
else {
ctxt.setAttribute(attr, val, PageContext.PAGE_SCOPE);
}
}
}
}