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


Java HttpServletRequest.getAttributeNames方法代碼示例

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


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

示例1: showRequestAttributes

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 *  Displays the request attributes for debugging..
 *
 * @param  request  Description of the Parameter
 */
private void showRequestAttributes(HttpServletRequest request) {
	if (debug) {
		prtln("Request Attributes");
		for (Enumeration e = request.getAttributeNames(); e.hasMoreElements(); ) {
			String attribute = (String) e.nextElement();
			Object o = request.getAttribute(attribute);
			if (o instanceof String) {
				System.out.println("\t" + attribute + ": " + (String) o);
			}
			else {
				System.out.println("\t" + attribute + " (" + o.getClass().getName() + ")");
				try {
					System.out.println("\t\t" + o.toString());
				} catch (Throwable t) {}
			}
		}
	}
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:24,代碼來源:SchemEditUtils.java

示例2: ServletRequestCopy

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public ServletRequestCopy(HttpServletRequest request) {
	this.servletPath = request.getServletPath();
	this.contextPath = request.getContextPath();
	this.pathInfo = request.getPathInfo();
	this.requestUri = request.getRequestURI();
	this.requestURL = request.getRequestURL();
	this.method = request.getMethod();
	this.serverName = request.getServerName();
	this.serverPort = request.getServerPort();
	this.protocol = request.getProtocol();
	this.scheme = request.getScheme();
	
	
	/*
	 * have to comment out below two lines as otherwise web socket will
	 * report UnSupportedOperationException upon connection
	 */
	//this.characterEncoding = request.getCharacterEncoding();
	//this.contentType = request.getContentType();
	//this.requestedSessionId = request.getRequestedSessionId();
	this.characterEncoding = null;
	this.contentType = null;
	this.requestedSessionId = null;
	
	this.locale = request.getLocale();
	this.locales = request.getLocales();
	this.isSecure = request.isSecure();
	this.remoteUser = request.getRemoteUser();
	this.remoteAddr = request.getRemoteAddr();
	this.remoteHost = request.getRemoteHost();
	this.remotePort = request.getRemotePort();
	this.localAddr = request.getLocalAddr();
	this.localName = request.getLocalName();
	this.localPort = request.getLocalPort();
	this.pathTranslated = request.getPathTranslated();
	this.principal = request.getUserPrincipal();

	HttpSession session = request.getSession(true);
	httpSession = new HttpSessionCopy(session);

	String s;
	Enumeration<String> e = request.getHeaderNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		Enumeration<String> headerValues = request.getHeaders(s);
		this.headers.put(s, headerValues);
	}

	e = request.getAttributeNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		attributes.put(s, request.getAttribute(s));
	}

	e = request.getParameterNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		parameters.put(s, request.getParameterValues(s));
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:61,代碼來源:ServletRequestCopy.java

示例3: printAttributes

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Print attributes of a HTTP request for debug purposes
 *
 * @param httpRequest
 */
public static void printAttributes(HttpServletRequest httpRequest) {

    System.out.println();
    System.out.println("Attributes of: " + httpRequest);
    Enumeration<String> names = httpRequest.getAttributeNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        Object value = httpRequest.getAttribute(name);
        System.out.println("\t # Name: " + name);
        System.out.println("\t   Value: " + value);
    }
}
 
開發者ID:remipassmoilesel,項目名稱:simple-hostel-management,代碼行數:18,代碼來源:Utils.java

示例4: getIlluminatiProcId

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Deprecated
private void getIlluminatiProcId (HttpServletRequest request) {
    final Enumeration<String> enumeration = request.getAttributeNames();

    while (enumeration.hasMoreElements()) {
        final String key = enumeration.nextElement();
        final String value = request.getAttribute(key).toString();

        if ("illuminatiProcId".equals(key)) {
            this.illuminatiProcId = value;
            break;
        }
    }
}
 
開發者ID:LeeKyoungIl,項目名稱:illuminati,代碼行數:15,代碼來源:RequestHeaderModel.java

示例5: setRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Set the request that we are wrapping.
 *
 * @param request The new wrapped request
 */
void setRequest(HttpServletRequest request) {

    super.setRequest(request);

    // Initialize the attributes for this request
    synchronized (attributes) {
        attributes.clear();
        Enumeration names = request.getAttributeNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            if( ! ( Globals.REQUEST_URI_ATTR.equals(name) ||
                    Globals.SERVLET_PATH_ATTR.equals(name) ) ) {
                Object value = request.getAttribute(name);
                attributes.put(name, value);
            }
        }
    }

    // Initialize the parameters for this request
    synchronized (parameters) {
        parameters = copyMap(request.getParameterMap());
    }

    // Initialize the path elements for this request
    contextPath = request.getContextPath();
    pathInfo = request.getPathInfo();
    queryString = request.getQueryString();
    requestURI = request.getRequestURI();
    servletPath = request.getServletPath();

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:37,代碼來源:ApplicationHttpRequest.java

示例6: testNonDefaultAttributes

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public void testNonDefaultAttributes() throws Exception {
    WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
    HttpServletRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, new ServletUnitContext(), new Hashtable(), NO_MESSAGE_BODY );
    Object value = new Integer(1);

    request.setAttribute( "one", value );

    assertEquals( "attribute one", value, request.getAttribute( "one" ) );

    Enumeration names = request.getAttributeNames();
    assertTrue( "attribute enumeration should not be empty", names.hasMoreElements() );
    assertEquals( "contents in enumeration", "one", names.nextElement() );
    assertTrue( "attribute enumeration should now be empty", !names.hasMoreElements() );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:15,代碼來源:HttpServletRequestTest.java


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