当前位置: 首页>>代码示例>>Java>>正文


Java PageContext类代码示例

本文整理汇总了Java中javax.servlet.jsp.PageContext的典型用法代码示例。如果您正苦于以下问题:Java PageContext类的具体用法?Java PageContext怎么用?Java PageContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PageContext类属于javax.servlet.jsp包,在下文中一共展示了PageContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVocabTreeMenu

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 *  Generates a Javascript Tree Menu (collapsable hierarchy) of the specified
 *  part of the vocabulary
 *
 * @param  group     colon-seperated specifier of the part of the vocab
 *      hierarchy which is to be displayed
 * @param  system
 * @param  page
 * @param  language
 * @return           the Javascript code defining the menu
 */
public synchronized String getVocabTreeMenu( String system,
                                             String language,
                                             String group,
                                             PageContext page ) {
	if ( vocabTreeMenuCache.get( system + language + group ) != null ) {
		Date now = new Date();
		if ( ( now.getTime() - ( (Date)vocabTreeMenuCacheDate.get( system + language + group ) ).getTime() )
			 < ( VOCAB_TREE_CACHE_TIME ) ) {
			return (String)vocabTreeMenuCache.get( system + language + group );
		}
	}
	StringBuffer ret = new StringBuffer();
	String inputName = setCurrentTree( system, group );
	if ( inputName.startsWith( "ERROR:" ) ) {
		return errorDisplay( inputName, "getVocabTreeMenu" );
	}
	try {
		String abbrevLabel = currentNode.getAttribute( "textAbbrev" );
		if ( abbrevLabel == null ) {
			abbrevLabel = (String)currentNode.getAttribute( "text" );
		}
		ret.append( "var tm_" + currentNode.fieldId + "0 = new dlese_vocabList( \"tm_" + currentNode.fieldId + "0\", 0, \""
			 + currentNode.getAttribute( "text" ) + "\", \"" + abbrevLabel + "\" );\n" );
	}
	catch ( Exception e ) {
		e.printStackTrace();
	}
	String setList = "\ndlese_setList( \"" + currentNode.fieldId + "\" );\n";
	ret.append( vocabTreeMenu( currentNode, currentNode.fieldId + "0", currentNode.fieldId, page ) );
	ret.append( setList );
	vocabTreeMenuCache.put( system + language + group, ret.toString() );
	vocabTreeMenuCacheDate.put( system + language + group, new Date() );
	return ret.toString();
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:46,代码来源:MetadataVocabOPML.java

示例2: JspContextWrapper

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
public JspContextWrapper(JspContext jspContext,
        ArrayList<String> nestedVars, ArrayList<String> atBeginVars,
        ArrayList<String> atEndVars, Map<String,String> aliases) {
    this.invokingJspCtxt = (PageContext) jspContext;
    if (jspContext instanceof JspContextWrapper) {
        rootJspCtxt = ((JspContextWrapper)jspContext).rootJspCtxt;
    }
    else {
        rootJspCtxt = invokingJspCtxt;
    }
    this.nestedVars = nestedVars;
    this.atBeginVars = atBeginVars;
    this.atEndVars = atEndVars;
    this.pageAttributes = new HashMap<String, Object>(16);
    this.aliases = aliases;

    if (nestedVars != null) {
        this.originalNestedVars = new HashMap<String, Object>(nestedVars.size());
    }
    syncBeginTagFile();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:JspContextWrapper.java

示例3: message

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 * Look up and return a message string, based on the specified parameters.
 *
 * @param pageContext The PageContext associated with this request
 * @param bundle Name of the servlet context attribute for our
 *  message resources bundle
 * @param locale Name of the session attribute for our user's Locale
 * @param key Message key to be looked up and returned
 * @param args Replacement parameters for this message
 * @return message string
 * @exception JspException if a lookup error occurs (will have been
 *  saved in the request already)
 * @deprecated Use {@link org.apache.struts.taglib.TagUtils#message(PageContext,String,String,String,Object[])} instead.
 * This will be removed after Struts 1.2.
 */
public static String message(
        PageContext pageContext,
        String bundle,
        String locale,
        String key,
        Object args[])
        throws JspException {
    // :TODO: Remove afer Struts 1.2

    return TagUtils.getInstance().message(
            pageContext,
            bundle,
            locale,
            key,
            args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:RequestUtils.java

示例4: getPageContext

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
@Override
public PageContext getPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {

    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                this, servlet, request, response, errorPageURL,
                needsSession, bufferSize, autoflush);
        return AccessController.doPrivileged(dp);
    } else {
        return internalGetPageContext(servlet, request, response,
                errorPageURL, needsSession,
                bufferSize, autoflush);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:JspFactoryImpl.java

示例5: setValue

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
@Override
public void setValue(ELContext context, Object base, Object property,
        Object value) throws NullPointerException,
        PropertyNotFoundException, PropertyNotWritableException,
        ELException {
    if (context == null) {
        throw new NullPointerException();
    }

    if (base == null) {
        context.setPropertyResolved(true);
        if (property != null) {
            String key = property.toString();
            PageContext page = (PageContext) context
                    .getContext(JspContext.class);
            int scope = page.getAttributesScope(key);
            if (scope != 0) {
                page.setAttribute(key, value, scope);
            } else {
                page.setAttribute(key, value);
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:ScopedAttributeELResolver.java

示例6: setAttribute

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 * Store bean in requested context.
 * If scope is <code>null</code>, save it in REQUEST_SCOPE context.
 *
 * @param pageContext Current pageContext.
 * @param name Name of the bean.
 * @param scope Scope under which bean is saved (page, request, session, application)
 *  or <code>null</code> to store in <code>request()</code> instead.
 * @param value Bean value to store.
 *
 * @exception JspException Scope name is not recognized as a valid scope
 */
public static void setAttribute(
    PageContext pageContext,
    String name,
    Object value,
    String scope)
    throws JspException {
        
    if (scope == null)
        pageContext.setAttribute(name, value, PageContext.REQUEST_SCOPE);
    else if (scope.equalsIgnoreCase("page"))
        pageContext.setAttribute(name, value, PageContext.PAGE_SCOPE);
    else if (scope.equalsIgnoreCase("request"))
        pageContext.setAttribute(name, value, PageContext.REQUEST_SCOPE);
    else if (scope.equalsIgnoreCase("session"))
        pageContext.setAttribute(name, value, PageContext.SESSION_SCOPE);
    else if (scope.equalsIgnoreCase("application"))
        pageContext.setAttribute(name, value, PageContext.APPLICATION_SCOPE);
    else {
        throw new JspException("Error - bad scope name '" + scope + "'");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:TagUtils.java

示例7: getFileText

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 *  Reads the given file and returns its contents as a string
 *
 * @param  filename
 * @param  page
 * @return           The fileText value
 */
private synchronized String getFileText( String filename, PageContext page ) {
	StringBuffer ret = new StringBuffer();
	try {
		BufferedReader in = new BufferedReader( new FileReader( page.getServletContext().getRealPath( filename ) ) );
		String s = null;
		while ( ( s = in.readLine() ) != null ) {
			ret.append( s );
		}
	}
	catch ( FileNotFoundException fnfe ) {
		System.err.println( "File not found - " );
		System.err.println( fnfe.getClass() + " " + fnfe.getMessage() );
	}
	catch ( IOException ioe ) {
		System.err.println( "Exception occurred reading " + filename );
		System.err.println( ioe.getClass() + " " + ioe.getMessage() );
	}
	return ret.toString();
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:27,代码来源:MetadataVocabTermsGroups.java

示例8: getResponseOPML

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 *  Gets the re-ordered/grouped/labeled OPML tree of metadata values from the
 *  cache created by setResponseGroup()
 *
 * @param  context  JSP page context
 * @return          OPML for the group specified with setResponseGroup() and
 *      trimmed to the subset indicated by values passed into setResponse()
 * @see             MetadataVocab#setResponseValue(String,PageContext)
 * @see             MetadataVocab#setResponseList(String[],PageContext)
 * @see             MetadataVocab#setResponseList(ArrayList,PageContext)
 * @see             MetadataVocab#setResponseGroup(PageContext,String,String,String,String,String)
 */
public synchronized String getResponseOPML( PageContext context ) {
	String ret = "";
	MetadataVocabResponseMap responseMap = (MetadataVocabResponseMap)context.findAttribute( "metadataVocabResponseMap" );
	if ( responseMap == null ) {
		ret = "<!-- MUI ERROR: metadataVocabResponseMap is empty -->";
	}
	if ( ( responseMap.metaVersion == null ) || responseMap.metaVersion.equals( "" ) ) {
		ret = getOPML( responseMap.metaFormat, getCurrentVersion( responseMap.metaFormat ),
			responseMap.audience, responseMap.language, responseMap.field, responseMap, false );
	}
	else {
		ret = getOPML( responseMap.metaFormat, responseMap.metaVersion,
			responseMap.audience, responseMap.language, responseMap.field, responseMap, false );
	}
	if ( ret.indexOf( "<outline" ) == -1 ) {
		ret = "";
	}
	return ret;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:32,代码来源:MetadataVocabOPML.java

示例9: getHtmlIdPrefix

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/** Get the HTML id for the form. This is based on the application rule
 * "jaffa.widgets.form.idFormat" which can have the following values
 * <ul>
 * <li>none - No id will be used for the form
 * <li>formname - The struts form name will be used
 * <li>index - an index value, based on the number of forms on the page will be used.
 * The value will be prefixed with 'j', so the first form will be id='j0'
 * <li>class - Will used the classname of the formbean (without the package name) for the id
 * </ul>
 * Older version of JAFFA used the equivilent of 'formname' which is the default if nothing is set.
 */
public String getHtmlIdPrefix() {
    if(m_htmlName!=null) {
        m_htmlIdPrefix=m_htmlName;
    } else if(m_htmlIdPrefix==null) {
        if(ID_FORMAT_INDEX.equals(m_idFormat)) {
            //Look for a index counter in the request
            Integer index = (Integer)pageContext.getAttribute(FORM_TAG_INDEX,PageContext.REQUEST_SCOPE);
            if(index==null)
                index=new Integer(1);
            m_htmlIdPrefix="j" + index;
            pageContext.setAttribute(FORM_TAG_INDEX,new Integer(index.intValue()+1),PageContext.REQUEST_SCOPE);
        } else if(ID_FORMAT_NONE.equals(m_idFormat))
            // use no id
            m_htmlIdPrefix="";
        else if(ID_FORMAT_CLASS.equals(m_idFormat)) {
            // Use the class name (exclude the package)
            m_htmlIdPrefix=StringHelper.getShortClassName(FormTag.class);
        } else {
            // Default to original behavior, and use the struts Bean name
            m_htmlIdPrefix=getBeanName();
        }
    }
    return m_htmlIdPrefix;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:36,代码来源:FormTag.java

示例10: setupTag

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 *  Get the vocab object from the page context and expand system to be a
 *  concatenation of system, interface, and language
 *
 * @param  pageContext
 * @exception  JspException
 */
public void setupTag( PageContext pageContext ) throws JspException {
	String contextAttributeName = (String)pageContext.getServletContext().getInitParameter( "metadataVocabInstanceAttributeName" );
	vocab = (MetadataVocab)pageContext.findAttribute( contextAttributeName );
	if ( vocab == null ) {
		System.out.println( "Looked for vocab in " + contextAttributeName );
		throw new JspException( "Vocabulary not found" );
	}
	else {
		try {
			metaVersion = vocab.getCurrentVersion( metaFormat );
		}
		catch ( Exception e ) {
			new JspException( "No current version found for metadata framework " + metaFormat );
		}
		system = metaFormat + "/" + metaVersion + "/" + audience + "/" + language + "/" + field;
		( (MetadataVocabOPML)vocab ).setCurrentTree( system, subGroup );
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:26,代码来源:MetadataVocabTag.java

示例11: setupTag

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 *  Get the vocab object from the page context and expand system to be a
 *  concatenation of system, interface, and language
 *
 * @param  pageContext
 * @exception  JspException
 */
public void setupTag( PageContext pageContext ) throws JspException {
	vocab = (MetadataVocab)pageContext.findAttribute( "MetadataVocab" );
	if ( vocab == null ) {
		throw new JspException( "Vocabulary not found" );
	}
	else {
		if ( group != null ) {
			group = stringUtil.replace( group, " ", "_", false );
		}
		else {
			group = "";
		}
		system = system + "." + interfce + "." + language;
	}
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:23,代码来源:MetadataVocabTag.java

示例12: doEndTag

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
public int doEndTag() throws JspException {

        // Rewrite and encode the url.
        String result = formatUrl();

        // Store or print the output
        if (var != null)
            pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE);
        else {
            try {
                pageContext.getOut().print(result);
            } catch (IOException x) {
                throw new JspTagException(x);
            }
        }
        return EVAL_PAGE;
    }
 
开发者ID:airsonic,项目名称:airsonic,代码行数:18,代码来源:UrlTag.java

示例13: setValue

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
@Override
public void setValue(ELContext context, Object base, Object property, Object value)
		throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException {
	if (context == null) {
		throw new NullPointerException();
	}

	if (base == null) {
		context.setPropertyResolved(true);
		if (property != null) {
			String key = property.toString();
			PageContext page = (PageContext) context.getContext(JspContext.class);
			int scope = page.getAttributesScope(key);
			if (scope != 0) {
				page.setAttribute(key, value, scope);
			} else {
				page.setAttribute(key, value);
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:ScopedAttributeELResolver.java

示例14: getScope

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
/**
 * Determines the scope for a given input {@code String}.
 * <p>If the {@code String} does not match 'request', 'session',
 * 'page' or 'application', the method will return {@link PageContext#PAGE_SCOPE}.
 * @param scope the {@code String} to inspect
 * @return the scope found, or {@link PageContext#PAGE_SCOPE} if no scope matched
 * @throws IllegalArgumentException if the supplied {@code scope} is {@code null}
 */
public static int getScope(String scope) {
	Assert.notNull(scope, "Scope to search for cannot be null");
	if (scope.equals(SCOPE_REQUEST)) {
		return PageContext.REQUEST_SCOPE;
	}
	else if (scope.equals(SCOPE_SESSION)) {
		return PageContext.SESSION_SCOPE;
	}
	else if (scope.equals(SCOPE_APPLICATION)) {
		return PageContext.APPLICATION_SCOPE;
	}
	else {
		return PageContext.PAGE_SCOPE;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:TagUtils.java

示例15: initialize

import javax.servlet.jsp.PageContext; //导入依赖的package包/类
public final void initialize(PageContext pagecontext)
    throws ServletException
{
    m_application = pagecontext.getServletContext();
    m_request = (HttpServletRequest)pagecontext.getRequest();
    m_response = (HttpServletResponse)pagecontext.getResponse();
}
 
开发者ID:yuanxy,项目名称:all-file,代码行数:8,代码来源:SmartUpload.java


注:本文中的javax.servlet.jsp.PageContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。