Java 类javax.servlet.jsp.PageContext 实例源码

项目:joai-project    文件:MetadataVocabOPML.java   
/**
 *  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();
}
项目:tomcat7    文件:JspContextWrapper.java   
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();
}
项目:lams    文件:RequestUtils.java   
/**
 * 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);
}
项目:apache-tomcat-7.0.73-with-comment    文件:JspFactoryImpl.java   
@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);
    }
}
项目:tomcat7    文件:ScopedAttributeELResolver.java   
@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);
            }
        }
    }
}
项目:lams    文件:TagUtils.java   
/**
 * 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 + "'");
    }
}
项目:joai-project    文件:MetadataVocabTermsGroups.java   
/**
 *  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();
}
项目:apache-tomcat-7.0.73-with-comment    文件:JspContextWrapper.java   
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();
}
项目:joai-project    文件:MetadataVocabOPML.java   
/**
 *  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;
}
项目:jaffa-framework    文件:FormTag.java   
/** 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;
}
项目:joai-project    文件:MetadataVocabTag.java   
/**
 *  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 );
    }
}
项目:joai-project    文件:MetadataVocabTag.java   
/**
 *  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;
    }
}
项目:airsonic    文件:UrlTag.java   
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;
    }
项目:lazycat    文件:ScopedAttributeELResolver.java   
@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);
            }
        }
    }
}
项目:lams    文件:TagUtils.java   
/**
 * 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;
    }
}
项目:all-file    文件:SmartUpload.java   
public final void initialize(PageContext pagecontext)
    throws ServletException
{
    m_application = pagecontext.getServletContext();
    m_request = (HttpServletRequest)pagecontext.getRequest();
    m_response = (HttpServletResponse)pagecontext.getResponse();
}
项目:lazycat    文件:JspRuntimeLibrary.java   
/**
 * Returns the value of the javax.servlet.error.exception request attribute
 * value, if present, otherwise the value of the
 * javax.servlet.jsp.jspException request attribute value.
 *
 * This method is called at the beginning of the generated servlet code for
 * a JSP error page, when the "exception" implicit scripting language
 * variable is initialized.
 */
public static Throwable getThrowable(ServletRequest request) {
    Throwable error = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
    if (error == null) {
        error = (Throwable) request.getAttribute(PageContext.EXCEPTION);
        if (error != null) {
            /*
             * The only place that sets JSP_EXCEPTION is
             * PageContextImpl.handlePageException(). It really should set
             * SERVLET_EXCEPTION, but that would interfere with the
             * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we need
             * to set SERVLET_EXCEPTION.
             */
            request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, error);
        }
    }

    return error;
}
项目:lams    文件:TagUtils.java   
public String computeURL(
        PageContext pageContext,
        String forward,
        String href,
        String page,
        String action,
        String module,
        Map params,
        String anchor,
        boolean redirect)
        throws MalformedURLException {
        return this.computeURLWithCharEncoding(
                            pageContext,
                            forward,
                            href,
                            page,
                            action,
                            module,
                            params,
                            anchor,
                            redirect,
                            false);
}
项目:lams    文件:TagUtils.java   
public String computeURL(
        PageContext pageContext,
        String forward,
        String href,
        String page,
        String action,
        String module,
        Map params,
        String anchor,
        boolean redirect,
        boolean encodeSeparator)
        throws MalformedURLException {
            return computeURLWithCharEncoding(
            pageContext,
            forward,
            href,
            page,
            action,
            module,
            params,
            anchor,
            redirect,
            encodeSeparator,
            false
            );
}
项目:jaffa-framework    文件:CustomTag.java   
/**
 * Pop this tag from the top of the stack on exit. Validate that this is the top
 * of the stack as well.
 *
 * This has package static access for the FormTag that can't extent CustomTag
 *
 * @return top ICustomTag from the nested component stack
 */
static ICustomTag popParent(ICustomTag thisTag, PageContext pageContext) {
    try {
        Stack stack = CustomTag.getNestedComponentStack(pageContext);
        if (stack == null) {
            log.fatal("CustomTag.popParent: Stack Was NULL, expected " + thisTag);
            return null;
        }
        ICustomTag me = (ICustomTag) stack.pop();
        if (log.isDebugEnabled())
            log.debug("CustomTag.popParent: parent from top of stack pageContext stack: " + thisTag.getParent());
        if(!thisTag.equals(me))
            log.fatal("CustomTag.popParent: Top of Stack Was " + me + ", expected " + thisTag);
        return me;
    } catch (Exception ee) {
        log.error("Error in CustomTag.popParent: " + ee);
    }
    return null;
}
项目:lams    文件:BaseTag.java   
/**
 * Process the start of this tag.
 *
 * @exception JspException if a JSP exception has occurred
 */
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String serverName = (this.server == null) ? request.getServerName() : this.server;

    String baseTag =
        renderBaseElement(
            request.getScheme(),
            serverName,
            request.getServerPort(),
            request.getRequestURI());

    JspWriter out = pageContext.getOut();
    try {
        out.write(baseTag);
    } catch (IOException e) {
        pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
        throw new JspException(messages.getMessage("common.io", e.toString()));
    }

    return EVAL_BODY_INCLUDE;
}
项目:lazycat    文件:ScopedAttributeELResolver.java   
@Override
public Object getValue(ELContext context, Object base, Object property)
        throws NullPointerException, PropertyNotFoundException, 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);
            return page.findAttribute(key);
        }
    }

    return null;
}
项目:tomcat7    文件:Util.java   
/** Utility methods
 * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
 */
public static String resolveUrl(
        String url, String context, PageContext pageContext)
throws JspException {
    // don't touch absolute URLs
    if (isAbsoluteUrl(url))
        return url;

    // normalize relative URLs against a context root
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
    if (context == null) {
        if (url.startsWith("/"))
            return (request.getContextPath() + url);
        else
            return url;
    } else {
        if (!context.startsWith("/") || !url.startsWith("/")) {
            throw new JspTagException(
            "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
        }
        if (context.equals("/")) {
            // Don't produce string starting with '//', many
            // browsers interpret this as host name, not as
            // path on same host.
            return url;
        } else {
            return (context + url);
        }
    }
}
项目:lams    文件:ImplicitObjectELResolver.java   
/**
 *
 * Creates the Map that maps init parameter name to single init
 * parameter value.
 **/
public static Map<String, String> createInitParamMap(PageContext pContext)
{
  final ServletContext context = pContext.getServletContext ();
  return new EnumeratedMap<String, String> ()
    {
      public Enumeration<String> enumerateKeys () 
      {
        return context.getInitParameterNames ();
      }

      public String getValue (Object pKey) 
      {
        if (pKey instanceof String) {
          return context.getInitParameter ((String) pKey);
        }
        else {
          return null;
        }
      }

      public boolean isMutable ()
      {
        return false;
      }
    };
}
项目:tomcat7    文件:JspFactoryImpl.java   
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {
    try {
        PageContext pc;
        if (USE_POOL) {
            PageContextPool pool = localPool.get();
            if (pool == null) {
                pool = new PageContextPool();
                localPool.set(pool);
            }
            pc = pool.get();
            if (pc == null) {
                pc = new PageContextImpl();
            }
        } else {
            pc = new PageContextImpl();
        }
        pc.initialize(servlet, request, response, errorPageURL, 
                needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        ExceptionUtils.handleThrowable(ex);
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
项目:lams    文件:ComponentContext.java   
/**
 * 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);
}
项目:jaffa-framework    文件:TagHelper.java   
/** Returns a true if the current widget is enclosed inside another widget.
 * @param pageContext The PageContext of the jsp.
 * @return a true if the current widget is enclosed inside another widget.
 */
public static boolean isEnclosed(PageContext pageContext) {
    Boolean result = (Boolean) pageContext.findAttribute(ATTRIBUTE_ENCLOSED);
    if (result != null)
        return result.booleanValue();
    else
        return false;
}
项目:lams    文件:ImplicitObjectELResolver.java   
/**
 *
 * Creates the Map that maps header name to single header
 * value.
 **/
public static Map<String, String> createHeaderMap (PageContext pContext)
{
  final HttpServletRequest request =
    (HttpServletRequest) pContext.getRequest ();
  return new EnumeratedMap<String, String> ()
    {
      public Enumeration<String> enumerateKeys () 
      {
        return request.getHeaderNames ();
      }

      public String getValue (Object pKey) 
      {
        if (pKey instanceof String) {
          return request.getHeader ((String) pKey);
        }
        else {
          return null;
        }
      }

      public boolean isMutable ()
      {
        return false;
      }
    };
}
项目:tomcat7    文件:ImplicitObjectELResolver.java   
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;
}
项目:tomcat7    文件:TestPageContextImpl.java   
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
            this, req, resp, null, false, JspWriter.DEFAULT_BUFFER, true);
    JspWriter out = pageContext.getOut();
    if (Constants.DEFAULT_BUFFER_SIZE == out.getBufferSize()) {
        resp.getWriter().println("OK");
    } else {
        resp.getWriter().println("FAIL");
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ImplicitObjectELResolver.java   
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;
}
项目:jaffa-framework    文件:TagHelper.java   
/** A convenience method to return a hyperlink to the LabelEditor component.
 * A blank string will be returned, if the user does not have access to the component 'Jaffa.Admin.LabelEditor'.
 * @param pageContext The PageContext of the jsp.
 * @param labelFilter The label to be edited. The labelFilter should be of the type 'xyz', '[xyz]'. Values of the type 'abc [xyz] efg [zzz]' will be ignored and a blank string will be returned.
 * @return the HTML for the hyperlink to the LabelEditor component.
 */
public static String getLabelEditorLink(PageContext pageContext, String labelFilter) {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    // Perform the logic only if the user has been authenticated
    if (request.getUserPrincipal() != null) {
        String labelEditorPrefix = null;
        HttpSession session = request.getSession(false);
        if (session != null) {
            // Check the session for the cached prefix
            labelEditorPrefix = (String) session.getAttribute(ATTRIBUTE_LABEL_EDITOR_LINK_PREFIX);
            if (labelEditorPrefix == null) {
                labelEditorPrefix = constructLabelEditorLinkPrefix(request);
                session.setAttribute(ATTRIBUTE_LABEL_EDITOR_LINK_PREFIX, labelEditorPrefix);
            }
        } else {
            // No session, so simply create the prefix each time
            labelEditorPrefix = constructLabelEditorLinkPrefix(request);
        }

        if (labelEditorPrefix.length() > 0) {
            // Ensure that the labelFilter is of the type 'xyz' or '[xyz]'
            // Remove the outer token markers, if any
            // Then proceed only if no more token-markers exist
            labelFilter = MessageHelper.removeTokenMarkers(labelFilter);
            if (!MessageHelper.hasTokens(labelFilter))
                return labelEditorPrefix + labelFilter + LABEL_EDITOR_LINK_SUFFIX;
        }
    }

    // We'll reach this point if the user is not aunthenticated or has no access to the component or if the labelFilter is invalid
    // Just return a blank String
    return "";
}
项目:lams    文件:ImplicitObjectELResolver.java   
/**
 *
 * 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;
}
项目:lazycat    文件:JspRuntimeLibrary.java   
/**
 * Use proprietaryEvaluate public static void
 * handleSetPropertyExpression(Object bean, String prop, String expression,
 * PageContext pageContext, VariableResolver variableResolver,
 * FunctionMapper functionMapper ) throws JasperException { try { Method
 * method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new
 * Object[] { pageContext.getExpressionEvaluator().evaluate( expression,
 * method.getParameterTypes()[0], variableResolver, functionMapper, null )
 * }); } catch (Exception ex) { throw new JasperException(ex); } }
 **/
public static void handleSetPropertyExpression(Object bean, String prop, String expression, PageContext pageContext,
        ProtectedFunctionMapper functionMapper) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { PageContextImpl.proprietaryEvaluate(expression,
                method.getParameterTypes()[0], pageContext, functionMapper, false) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:Util.java   
/** Utility methods
 * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
 */
public static String resolveUrl(
        String url, String context, PageContext pageContext)
throws JspException {
    // don't touch absolute URLs
    if (isAbsoluteUrl(url))
        return url;

    // normalize relative URLs against a context root
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
    if (context == null) {
        if (url.startsWith("/"))
            return (request.getContextPath() + url);
        else
            return url;
    } else {
        if (!context.startsWith("/") || !url.startsWith("/")) {
            throw new JspTagException(
            "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
        }
        if (context.equals("/")) {
            // Don't produce string starting with '//', many
            // browsers interpret this as host name, not as
            // path on same host.
            return url;
        } else {
            return (context + url);
        }
    }
}
项目:lams    文件:Util.java   
/**
 * Converts the given string description of a scope to the corresponding
 * PageContext constant.
 *
 * The validity of the given scope has already been checked by the
 * appropriate TLV.
 *
 * @param scope String description of scope
 *
 * @return PageContext constant corresponding to given scope description
 * 
 * taken from org.apache.taglibs.standard.tag.common.core.Util  
 */
public static int getScope(String scope){
    int ret = PageContext.PAGE_SCOPE;

    if("request".equalsIgnoreCase(scope)){
        ret = PageContext.REQUEST_SCOPE;
    }else if("session".equalsIgnoreCase(scope)){
        ret = PageContext.SESSION_SCOPE;
    }else if("application".equalsIgnoreCase(scope)){
        ret = PageContext.APPLICATION_SCOPE;
    }

    return ret;
}
项目:lams    文件:Util.java   
/** Utility methods
 * taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
 */
public static String resolveUrl(
        String url, String context, PageContext pageContext)
throws JspException {
    // don't touch absolute URLs
    if (isAbsoluteUrl(url))
        return url;

    // normalize relative URLs against a context root
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
    if (context == null) {
        if (url.startsWith("/"))
            return (request.getContextPath() + url);
        else
            return url;
    } else {
        if (!context.startsWith("/") || !url.startsWith("/")) {
            throw new JspTagException(
            "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
        }
        if (context.equals("/")) {
            // Don't produce string starting with '//', many
            // browsers interpret this as host name, not as
            // path on same host.
            return url;
        } else {
            return (context + url);
        }
    }
}
项目:lams    文件:RequestUtils.java   
/**
 * <p>Return the form action converted into a server-relative URL.</p>
 * @deprecated This will be removed after Struts 1.2.
 * Use {@link org.apache.struts.taglib.TagUtils#getActionMappingURL(String,PageContext)} instead.
 */
public static String getActionMappingURL(
        String action,
        PageContext pageContext) {
    // :TODO: Remove after Struts 1.2

    return TagUtils.getInstance().getActionMappingURL(action, pageContext);

}
项目:lams    文件:JspFactoryImpl.java   
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {
    try {
        PageContext pc;
        if (USE_POOL) {
            PageContextPool pool = localPool.get();
            if (pool == null) {
                pool = new PageContextPool();
                localPool.set(pool);
            }
            pc = pool.get();
            if (pc == null) {
                pc = new PageContextImpl();
            }
        } else {
            pc = new PageContextImpl();
        }
        pc.initialize(servlet, request, response, errorPageURL, 
                needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        /* FIXME: need to do something reasonable here!! */
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
项目:lams    文件:ImplicitObjectELResolver.java   
/**
 *
 * 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;
      }
    };
}