當前位置: 首頁>>代碼示例>>Java>>正文


Java PageContext.getRequest方法代碼示例

本文整理匯總了Java中javax.servlet.jsp.PageContext.getRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java PageContext.getRequest方法的具體用法?Java PageContext.getRequest怎麽用?Java PageContext.getRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.jsp.PageContext的用法示例。


在下文中一共展示了PageContext.getRequest方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCookieMap

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 *
 * Creates the Map that maps cookie name to the first matching
 * Cookie in request.getCookies().
 **/
public static Map<String, Cookie> createCookieMap (PageContext pContext)
{
  // Read all the cookies and construct the entire map
  HttpServletRequest request = (HttpServletRequest) pContext.getRequest ();
  Cookie [] cookies = request.getCookies ();
  Map<String, Cookie> ret = new HashMap<String, Cookie> ();
  for (int i = 0; cookies != null && i < cookies.length; i++) {
    Cookie cookie = cookies [i];
    if (cookie != null) {
      String name = cookie.getName ();
      if (!ret.containsKey (name)) {
        ret.put (name, cookie);
      }
    }
  }
  return ret;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:ImplicitObjectELResolver.java

示例2: 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

示例3: resolveUrl

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/** 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);
        }
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:34,代碼來源:Util.java

示例4: createParamMap

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 *
 * Creates the Map that maps parameter name to single parameter
 * value.
 **/
public static Map<String, String> createParamMap (PageContext pContext)
{
  final HttpServletRequest request =
    (HttpServletRequest) pContext.getRequest ();
  return new EnumeratedMap<String, String> ()
    {
      public Enumeration<String> enumerateKeys () 
      {
        return request.getParameterNames ();
      }

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

      public boolean isMutable ()
      {
        return false;
      }
    };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:ImplicitObjectELResolver.java

示例5: createParamsMap

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 *
 * Creates the Map that maps parameter name to an array of parameter
 * values.
 **/
public static Map<String, String[]> createParamsMap (PageContext pContext)
{
  final HttpServletRequest request =
    (HttpServletRequest) pContext.getRequest ();
  return new EnumeratedMap<String, String[]> ()
    {
      public Enumeration<String> enumerateKeys () 
      {
        return request.getParameterNames ();
      }

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

      public boolean isMutable ()
      {
        return false;
      }
    };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:ImplicitObjectELResolver.java

示例6: createHeaderMap

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 *
 * 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;
      }
    };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:ImplicitObjectELResolver.java

示例7: createHeadersMap

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 *
 * Creates the Map that maps header name to an array of header
 * values.
 **/
public static Map<String, String[]> createHeadersMap (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) {
          // Drain the header enumeration
          List<String> l = new ArrayList<String> ();
          Enumeration<String> e = request.getHeaders ((String) pKey);
          if (e != null) {
            while (e.hasMoreElements ()) {
              l.add (e.nextElement ());
            }
          }
          return l.toArray (new String [l.size ()]);
        }
        else {
          return null;
        }
      }

      public boolean isMutable ()
      {
        return false;
      }
    };
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:ImplicitObjectELResolver.java

示例8: getLabelEditorLink

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/** 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 "";
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:40,代碼來源:TagHelper.java

示例9: AuthUtil

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 * 構造方法
 */
public AuthUtil(PageContext context)
{
	this.request = (HttpServletRequest)context.getRequest();
	//this.response = (HttpServletResponse)context.getResponse();
	authService = (AuthService)BeanFactory.getBean("authService");
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:10,代碼來源:AuthUtil.java

示例10: resolveUrl

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 * 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);
		}
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:32,代碼來源:Util.java

示例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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:64,代碼來源:TagUtils.java

示例12: AuthLogin

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 * 構造方法
 */
public AuthLogin(PageContext context)
{
	this.request = (HttpServletRequest)context.getRequest();
	//this.response = (HttpServletResponse)context.getResponse();
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:9,代碼來源:AuthLogin.java

示例13: MyCookie

import javax.servlet.jsp.PageContext; //導入方法依賴的package包/類
/**
 * 初始化cookie
 * @param context PageContext
 */
public MyCookie(PageContext context)
{
	this.response = (HttpServletResponse) context.getResponse();
	this.request = (HttpServletRequest) context.getRequest();
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:10,代碼來源:MyCookie.java


注:本文中的javax.servlet.jsp.PageContext.getRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。