本文整理匯總了Java中org.apache.commons.httpclient.Cookie.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Cookie.getValue方法的具體用法?Java Cookie.getValue怎麽用?Java Cookie.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.Cookie
的用法示例。
在下文中一共展示了Cookie.getValue方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getJSessionID
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
protected String getJSessionID() {
String jSessionID = null;
if (httpState != null) {
Cookie[] httpCookies = httpState.getCookies();
int len = httpCookies.length;
Cookie cookie = null;
for (int i=0; i<len; i++) {
cookie = httpCookies[i];
String cookieName = cookie.getName();
String cookieValue = cookie.getValue();
if (cookieName.equalsIgnoreCase("JSESSIONID")) {
jSessionID = cookieValue;
break;
}
}
}
return jSessionID;
}
示例2: formatCookieAsVer
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
* Return a string suitable for sending in a <tt>"Cookie"</tt> header
* as defined in RFC 2109 for backward compatibility with cookie version 0
* @param buffer The string buffer to use for output
* @param cookie The {@link Cookie} to be formatted as string
* @param version The version to use.
*/
private void formatCookieAsVer(final StringBuffer buffer, final Cookie cookie, int version) {
String value = cookie.getValue();
if (value == null) {
value = "";
}
formatParam(buffer, new NameValuePair(cookie.getName(), value), version);
if ((cookie.getPath() != null) && cookie.isPathAttributeSpecified()) {
buffer.append("; ");
formatParam(buffer, new NameValuePair("$Path", cookie.getPath()), version);
}
if ((cookie.getDomain() != null)
&& cookie.isDomainAttributeSpecified()) {
buffer.append("; ");
formatParam(buffer, new NameValuePair("$Domain", cookie.getDomain()), version);
}
}
示例3: cookiesAsString
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
private String cookiesAsString()
{
String result = "[";
for(Cookie c: this.cookies)
{
result = c.getName()+":"+c.getValue();
}
result += "]";
return result;
}
示例4: getCookieStrings
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public Vector<String> getCookieStrings() {
// Use the HandleCookie Property of the transaction to return or not the cookies.
//
// We noticed a Bug in tomcat when too much cookies where set in the response to the client. This causes a
// IndexOutOfBoundException: 4096 in coyote.
// To overcome this situation, now you can configure HandleCookies to false in the transaction to prevent cookies to be reflected
// to the client.
if (requestedObject instanceof AbstractHttpTransaction ) {
if (!((AbstractHttpTransaction)requestedObject).isHandleCookie())
return new Vector<String>();
}
Vector<String> cookies = new Vector<String>();
if (httpState != null) {
Cookie[] httpCookies = httpState.getCookies();
int len = httpCookies.length;
Cookie cookie = null;
String sCookie;
DateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss z", Locale.US);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
for (int i=0; i<len; i++) {
cookie = httpCookies[i];
sCookie = cookie.getName() + "=" + cookie.getValue() + ";";
sCookie += (cookie.getExpiryDate() != null) ? "expires=" + df.format(cookie.getExpiryDate())+ ";":"";
sCookie += "path=" + cookie.getPath() + ";";
sCookie += "domain=" + cookie.getDomain() + ";";
sCookie += cookie.getSecure() ? "secure": "";
cookies.add(sCookie);
}
}
return cookies;
}
示例5: formatCookie
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
public static String formatCookie(Cookie cookie) {
StringBuffer buf = new StringBuffer();
Date d = cookie.getExpiryDate();
String[][] datas = {
// {"$Version",Integer.toString(cookie.getVersion())},
{ cookie.getName(), cookie.getValue() }, { "$Domain", cookie.getDomain() },
{ "$Path", cookie.getPath() }, { "$Secure", Boolean.toString(cookie.getSecure()) },
{ "$Date", d == null ? "null" : DateFormat.getDateTimeInstance().format(d) } };
buf.append(datas[0][0] + "=" + datas[0][1]);
for (int i = 1; i < datas.length; i++) {
if (datas[i][1] != null)
buf.append("; " + datas[i][0] + "=" + datas[i][1]);
}
return buf.toString();
}
示例6: formatCookie
import org.apache.commons.httpclient.Cookie; //導入方法依賴的package包/類
/**
* Return a string suitable for sending in a <tt>"Cookie"</tt> header
* @param cookie a {@link Cookie} to be formatted as string
* @return a string suitable for sending in a <tt>"Cookie"</tt> header.
*/
public String formatCookie(Cookie cookie) {
LOG.trace("enter CookieSpecBase.formatCookie(Cookie)");
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
StringBuffer buf = new StringBuffer();
buf.append(cookie.getName());
buf.append("=");
String s = cookie.getValue();
if (s != null) {
buf.append(s);
}
return buf.toString();
}