亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? httputils.java

?? 使用java語言編寫的小應用程序
?? JAVA
字號:
/*
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights 
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:  
 *       "This product includes software developed by the 
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written 
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * ====================================================================
 *
 * This source code implements specifications defined by the Java
 * Community Process. In order to remain compliant with the specification
 * DO NOT add / change / or delete method signatures!
 */ 


package javax.servlet.http;

import javax.servlet.ServletInputStream;
import java.util.Hashtable;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.io.IOException;


/**
 * Provides a collection of methods that are useful
 * in writing HTTP servlets.
 *
 * @author	Various
 * @version 	$Version$
 *
 */


public class HttpUtils {

    private static final String LSTRING_FILE =
	"javax.servlet.http.LocalStrings";
    private static ResourceBundle lStrings =
	ResourceBundle.getBundle(LSTRING_FILE);
    
    static Hashtable nullHashtable = new Hashtable();
    
    
    
    /**
     * Constructs an empty <code>HttpUtils</code> object.
     *
     */

    public HttpUtils() {}
    
    
    
    

    /**
     *
     * Parses a query string passed from the client to the
     * server and builds a <code>HashTable</code> object
     * with key-value pairs. 
     * The query string should be in the form of a string
     * packaged by the GET or POST method, that is, it
     * should have key-value pairs in the form <i>key=value</i>,
     * with each pair separated from the next by a & character.
     *
     * <p>A key can appear more than once in the query string
     * with different values. However, the key appears only once in 
     * the hashtable, with its value being
     * an array of strings containing the multiple values sent
     * by the query string.
     * 
     * <p>The keys and values in the hashtable are stored in their
     * decoded form, so
     * any + characters are converted to spaces, and characters
     * sent in hexadecimal notation (like <i>%xx</i>) are
     * converted to ASCII characters.
     *
     * @param s		a string containing the query to be parsed
     *
     * @return		a <code>HashTable</code> object built
     * 			from the parsed key-value pairs
     *
     * @exception IllegalArgumentException	if the query string 
     *						is invalid
     *
     */

    static public Hashtable parseQueryString(String s) {

	String valArray[] = null;
	
	if (s == null) {
	    throw new IllegalArgumentException();
	}
	Hashtable ht = new Hashtable();
	StringBuffer sb = new StringBuffer();
	StringTokenizer st = new StringTokenizer(s, "&");
	while (st.hasMoreTokens()) {
	    String pair = (String)st.nextToken();
	    int pos = pair.indexOf('=');
	    if (pos == -1) {
		// XXX
		// should give more detail about the illegal argument
		throw new IllegalArgumentException();
	    }
	    String key = parseName(pair.substring(0, pos), sb);
	    String val = parseName(pair.substring(pos+1, pair.length()), sb);
	    /*
	    System.out.println(key);
	    System.out.println(val);

	    if (ht.containsKey(key)) {
		String oldVals[] = (String []) ht.get(key);
		valArray = new String[oldVals.length + 1];
		for (int i = 0; i < oldVals.length; i++) 
		    valArray[i] = oldVals[i];
		valArray[oldVals.length] = val;
	    } else {
		valArray = new String[1];
		valArray[0] = val;
	    }
    	    ht.put(key, valArray);

*/	    
	    ht.put(key, val);
	}
	return ht;
    }




    /**
     *
     * Parses data from an HTML form that the client sends to 
     * the server using the HTTP POST method and the 
     * <i>application/x-www-form-urlencoded</i> MIME type.
     *
     * <p>The data sent by the POST method contains key-value
     * pairs. A key can appear more than once in the POST data
     * with different values. However, the key appears only once in 
     * the hashtable, with its value being
     * an array of strings containing the multiple values sent
     * by the POST method.
     *
     * <p>The keys and values in the hashtable are stored in their
     * decoded form, so
     * any + characters are converted to spaces, and characters
     * sent in hexadecimal notation (like <i>%xx</i>) are
     * converted to ASCII characters.
     *
     *
     *
     * @param len	an integer specifying the length,
     *			in characters, of the 
     *			<code>ServletInputStream</code>
     *			object that is also passed to this
     *			method
     *
     * @param in	the <code>ServletInputStream</code>
     *			object that contains the data sent
     *			from the client
     * 
     * @return		a <code>HashTable</code> object built
     *			from the parsed key-value pairs
     *
     *
     * @exception IllegalArgumentException	if the data
     *			sent by the POST method is invalid
     *
     */
     

    static public Hashtable parsePostData(int len, 
					  ServletInputStream in)
    {
	// XXX
	// should a length of 0 be an IllegalArgumentException
	
	if (len <=0)
	    return new Hashtable(); // cheap hack to return an empty hash

	if (in == null) {
	    throw new IllegalArgumentException();
	}
	
	//
	// Make sure we read the entire POSTed body.
	//
        byte[] postedBytes = new byte [len];
        try {
            int offset = 0;
       
	    do {
		int inputLen = in.read (postedBytes, offset, len - offset);
		if (inputLen <= 0) {
		    String msg = lStrings.getString("err.io.short_read");
		    throw new IllegalArgumentException (msg);
		}
		offset += inputLen;
	    } while ((len - offset) > 0);

	} catch (IOException e) {
	    throw new IllegalArgumentException(e.getMessage());
	}

        // XXX we shouldn't assume that the only kind of POST body
        // is FORM data encoded using ASCII or ISO Latin/1 ... or
        // that the body should always be treated as FORM data.
        //

        try {
            String postedBody = new String(postedBytes, 0, len, "8859_1");
            return parseQueryString(postedBody);
        } catch (java.io.UnsupportedEncodingException e) {
            // XXX function should accept an encoding parameter & throw this
            // exception.  Otherwise throw something expected.
            throw new IllegalArgumentException(e.getMessage());
        }
    }




    /*
     * Parse a name in the query string.
     */

    static private String parseName(String s, StringBuffer sb) {
	sb.setLength(0);
	for (int i = 0; i < s.length(); i++) {
	    char c = s.charAt(i); 
	    switch (c) {
	    case '+':
		sb.append(' ');
		break;
	    case '%':
		try {
		    sb.append((char) Integer.parseInt(s.substring(i+1, i+3), 
						      16));
		    i += 2;
		} catch (NumberFormatException e) {
		    // XXX
		    // need to be more specific about illegal arg
		    throw new IllegalArgumentException();
		} catch (StringIndexOutOfBoundsException e) {
		    String rest  = s.substring(i);
		    sb.append(rest);
		    if (rest.length()==2)
			i++;
		}
		
		break;
	    default:
		sb.append(c);
		break;
	    }
	}
	return sb.toString();
    }




    /**
     *
     * Reconstructs the URL the client used to make the request,
     * using information in the <code>HttpServletRequest</code> object.
     * The returned URL contains a protocol, server name, port
     * number, and server path, but it does not include query
     * string parameters.
     * 
     * <p>Because this method returns a <code>StringBuffer</code>,
     * not a string, you can modify the URL easily, for example,
     * to append query parameters.
     *
     * <p>This method is useful for creating redirect messages
     * and for reporting errors.
     *
     * @param req	a <code>HttpServletRequest</code> object
     *			containing the client's request
     * 
     * @return		a <code>StringBuffer</code> object containing
     *			the reconstructed URL
     *
     */

    public static StringBuffer getRequestURL (HttpServletRequest req) {
	StringBuffer url = new StringBuffer ();
	String scheme = req.getScheme ();
	int port = req.getServerPort ();
	String urlPath = req.getRequestURI();
	
	//String		servletPath = req.getServletPath ();
	//String		pathInfo = req.getPathInfo ();

	url.append (scheme);		// http, https
	url.append ("://");
	url.append (req.getServerName ());
	if ((scheme.equals ("http") && port != 80)
		|| (scheme.equals ("https") && port != 443)) {
	    url.append (':');
	    url.append (req.getServerPort ());
	}
	//if (servletPath != null)
	//    url.append (servletPath);
	//if (pathInfo != null)
	//    url.append (pathInfo);
	url.append(urlPath);
	return url;
    }
}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
青青草97国产精品免费观看 | 91成人网在线| 91精品国产综合久久久久久漫画| 久久老女人爱爱| 午夜精品爽啪视频| av电影一区二区| 久久综合色天天久久综合图片| 亚洲免费大片在线观看| 国产乱对白刺激视频不卡| 精品视频一区三区九区| 国产色一区二区| 日韩成人免费看| 欧美三级乱人伦电影| 国产精品无人区| 国产美女在线精品| 日韩午夜在线影院| 亚洲国产精品自拍| 日本精品免费观看高清观看| 国产精品视频在线看| 国产精品原创巨作av| 精品国产乱子伦一区| 99麻豆久久久国产精品免费优播| 中文字幕国产精品一区二区| 久久99国产精品久久| 日韩一区二区三区电影| 亚欧色一区w666天堂| 欧美午夜不卡视频| 亚洲精品videosex极品| 色综合久久九月婷婷色综合| 国产精品久久久久久久裸模| 成人av先锋影音| 国产精品国产三级国产有无不卡 | 国产在线播放一区三区四| 欧美精品777| 丝袜亚洲精品中文字幕一区| 欧美三级欧美一级| 天堂午夜影视日韩欧美一区二区| 欧美日韩国产美女| 麻豆精品一区二区综合av| 精品少妇一区二区三区日产乱码 | 欧美一区二区三区啪啪| 午夜精品福利一区二区三区蜜桃| 99久久精品情趣| 亚洲视频一二三区| 欧美亚洲国产一区二区三区va | 久久成人av少妇免费| 欧美不卡一区二区三区| 国产精品伊人色| 成人免费在线播放视频| 久久新电视剧免费观看| 国产成人亚洲精品青草天美| 国产精品久久久久久久久免费相片 | 日韩免费成人网| 国产精品中文欧美| 亚洲精选一二三| 欧美丰满少妇xxxbbb| 国产美女娇喘av呻吟久久| 国产婷婷色一区二区三区在线| 91尤物视频在线观看| 国产精品久久久99| 777奇米成人网| 黄页视频在线91| 国产欧美视频一区二区| 成人免费视频视频在线观看免费| 国产视频不卡一区| av一本久道久久综合久久鬼色| 亚洲精品视频一区二区| 日韩精品一区二区三区在线播放| 粉嫩aⅴ一区二区三区四区 | 色激情天天射综合网| 天天综合日日夜夜精品| 日本一区二区三区视频视频| 在线视频一区二区三| 国产在线精品一区二区不卡了| 国产精品护士白丝一区av| 日韩视频一区二区在线观看| 不卡在线视频中文字幕| 日韩电影免费在线观看网站| 中文字幕在线观看不卡视频| 日韩一级精品视频在线观看| 99久久免费视频.com| 久久av中文字幕片| 亚洲国产成人porn| 国产精品福利影院| 久久精品欧美日韩| 日韩一区和二区| 欧美日韩精品一区二区三区四区| 国产河南妇女毛片精品久久久 | 日韩欧美专区在线| 欧洲一区在线观看| 成人精品一区二区三区四区 | 老司机精品视频一区二区三区| 国产精品三级av在线播放| 欧美电影一区二区| 99热99精品| 国产精品中文字幕日韩精品| 日韩电影免费在线看| 亚洲国产精品精华液网站| 亚洲人成7777| 欧美精品vⅰdeose4hd| 国产米奇在线777精品观看| 夜夜嗨av一区二区三区四季av| 国产调教视频一区| 国产亚洲综合av| 久久久九九九九| 国产亚洲精品久| 久久久久国产精品人| 久久精品欧美一区二区三区不卡| 精品久久人人做人人爰| 91精品国产综合久久福利| 欧美日韩免费高清一区色橹橹 | 亚洲一区二区高清| 亚洲制服丝袜av| 亚洲综合精品久久| 亚洲亚洲人成综合网络| 亚洲午夜精品久久久久久久久| 一二三区精品福利视频| 午夜一区二区三区视频| 美女一区二区在线观看| 久久精工是国产品牌吗| 国产乱色国产精品免费视频| 国产成人免费av在线| 99久久精品免费看国产| 在线观看av一区二区| 欧美一级黄色片| 精品久久久三级丝袜| 国产欧美精品一区| 国产精品久久久久久久浪潮网站| 亚洲天堂2016| 亚洲成人动漫精品| 久久草av在线| av成人老司机| 欧美在线一区二区| 欧美大片在线观看一区| 久久久精品国产99久久精品芒果 | 99国产精品视频免费观看| 91丨porny丨国产| 欧美日韩在线精品一区二区三区激情| 欧美日韩一区二区三区免费看 | 欧美日韩国产经典色站一区二区三区| 在线不卡免费av| 久久午夜免费电影| 中文字幕国产一区| 丝袜美腿成人在线| 成人毛片老司机大片| 欧美日韩午夜在线| 国产欧美一区二区精品性色 | 成人黄色av电影| 欧美主播一区二区三区美女| 欧美乱熟臀69xxxxxx| 国产午夜久久久久| 天天综合日日夜夜精品| 成人午夜在线免费| 欧美日韩另类国产亚洲欧美一级| ww亚洲ww在线观看国产| 亚洲一二三四久久| 国产原创一区二区三区| 在线日韩一区二区| 国产欧美精品在线观看| 日本不卡在线视频| 色哟哟一区二区在线观看 | 一区二区三区中文字幕| 捆绑调教美女网站视频一区| 色综合久久88色综合天天6| 欧美精品一区二区三| 亚洲精品乱码久久久久久黑人 | 欧美在线观看一区二区| 久久精品一区二区三区不卡牛牛| 亚洲午夜久久久| 成人性生交大片免费看在线播放 | 精品欧美一区二区三区精品久久 | 一区二区免费看| 丁香激情综合五月| 精品成人免费观看| 日韩精品欧美精品| 欧美亚洲国产一区二区三区va | 欧美日韩激情一区二区三区| 日本一二三四高清不卡| 蜜桃在线一区二区三区| 欧美视频在线一区二区三区 | 欧美日韩一区成人| 自拍偷拍欧美精品| 国产成人啪免费观看软件 | 日韩一区二区三免费高清| 亚洲精品福利视频网站| 成人av资源下载| 国产欧美综合在线| 国产精品资源在线看| 26uuu亚洲综合色欧美| 男人的j进女人的j一区| 91精品国产一区二区三区| 亚洲成a人v欧美综合天堂| 欧美在线一区二区| 一区二区三区在线影院| 色悠悠亚洲一区二区| 一区二区欧美在线观看| 在线观看91视频| 婷婷一区二区三区| 51午夜精品国产| 免费日本视频一区|