Codota Logo
NameValuePair.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.apache.commons.httpclient.NameValuePair
constructor

Best Java code snippets using org.apache.commons.httpclient.NameValuePair.<init> (Showing top 20 results out of 765)

  • Common ways to obtain NameValuePair
private void myMethod () {
NameValuePair n =
  • Codota IconString name;String value;new NameValuePair(name, value)
  • Codota Iconvalues[0].getParameterByName("charset")
  • Codota Iconnew NameValuePair()
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 PostMethod post = new PostMethod("http://jakarata.apache.org/");
NameValuePair[] data = {
  new NameValuePair("user", "joe"),
  new NameValuePair("password", "bloggs")
};
post.setRequestBody(data);
// execute method and handle any error responses.
...
InputStream in = post.getResponseBodyAsStream();
// handle response.
origin: stackoverflow.com

 GetMethod method = new GetMethod("example.com/page"); 
method.setQueryString(new NameValuePair[] { 
  new NameValuePair("key", "value") 
});
origin: commons-httpclient/commons-httpclient

/**
 * Adds a new parameter to be used in the POST request body.
 *
 * @param paramName The parameter name to add.
 * @param paramValue The parameter value to add.
 *
 * @throws IllegalArgumentException if either argument is null
 *
 * @since 1.0
 */
public void addParameter(String paramName, String paramValue) 
throws IllegalArgumentException {
  LOG.trace("enter PostMethod.addParameter(String, String)");
  if ((paramName == null) || (paramValue == null)) {
    throw new IllegalArgumentException(
      "Arguments to addParameter(String, String) cannot be null");
  }
  super.clearRequestBody();
  this.params.add(new NameValuePair(paramName, paramValue));
}
origin: commons-httpclient/commons-httpclient

/**
 * Return a string suitable for sending in a <tt>"Cookie"</tt> header as
 * defined in RFC 2109
 * @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 RFC2109Spec.formatCookie(Cookie)");
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  int version = cookie.getVersion();
  StringBuffer buffer = new StringBuffer();
  formatParam(buffer, 
      new NameValuePair("$Version", Integer.toString(version)), 
      version);
  buffer.append("; ");
  formatCookieAsVer(buffer, cookie, version);
  return buffer.toString();
}
origin: commons-httpclient/commons-httpclient

public Header getVersionHeader() {
  ParameterFormatter formatter = new ParameterFormatter();
  StringBuffer buffer = new StringBuffer();
  formatter.format(buffer, new NameValuePair("$Version",
      Integer.toString(getVersion())));
  return new Header("Cookie2", buffer.toString(), true);
}

origin: commons-httpclient/commons-httpclient

params.add(new NameValuePair("username", uname));
params.add(new NameValuePair("realm", realm));
params.add(new NameValuePair("nonce", nonce));
params.add(new NameValuePair("uri", uri));
params.add(new NameValuePair("response", response));
  params.add(new NameValuePair("qop", getQopVariantString()));
  params.add(new NameValuePair("nc", NC));
  params.add(new NameValuePair("cnonce", this.cnonce));
  params.add(new NameValuePair("algorithm", algorithm));
  params.add(new NameValuePair("opaque", opaque));
origin: commons-httpclient/commons-httpclient

/**
 * Return a string suitable for sending in a <tt>"Cookie"</tt> header as
 * defined in RFC 2965
 * @param cookie a {@link org.apache.commons.httpclient.Cookie} to be formatted as string
 * @return a string suitable for sending in a <tt>"Cookie"</tt> header.
 */
public String formatCookie(final Cookie cookie) {
  LOG.trace("enter RFC2965Spec.formatCookie(Cookie)");
  if (cookie == null) {
    throw new IllegalArgumentException("Cookie may not be null");
  }
  if (cookie instanceof Cookie2) {
    Cookie2 cookie2 = (Cookie2) cookie;
    int version = cookie2.getVersion();
    final StringBuffer buffer = new StringBuffer();
    this.formatter.format(buffer, new NameValuePair("$Version", Integer.toString(version)));
    buffer.append("; ");
    doFormatCookie2(cookie2, buffer);
    return buffer.toString();
  } else {
    // old-style cookies are formatted according to the old rules
    return this.rfc2109.formatCookie(cookie);
  }
}
origin: commons-httpclient/commons-httpclient

/**
 * Create a RFC 2109 compliant <tt>"Cookie"</tt> header value containing all
 * {@link Cookie}s in <i>cookies</i> suitable for sending in a <tt>"Cookie"
 * </tt> header
 * @param cookies an array of {@link Cookie}s to be formatted
 * @return a string suitable for sending in a Cookie header.
 */
public String formatCookies(Cookie[] cookies) {
  LOG.trace("enter RFC2109Spec.formatCookieHeader(Cookie[])");
  int version = Integer.MAX_VALUE;
  // Pick the lowerest common denominator
  for (int i = 0; i < cookies.length; i++) {
    Cookie cookie = cookies[i];
    if (cookie.getVersion() < version) {
      version = cookie.getVersion();
    }
  }
  final StringBuffer buffer = new StringBuffer();
  formatParam(buffer, 
      new NameValuePair("$Version", Integer.toString(version)), 
      version);
  for (int i = 0; i < cookies.length; i++) {
    buffer.append("; ");
    formatCookieAsVer(buffer, cookies[i], version);
  }
  return buffer.toString();
}
origin: commons-httpclient/commons-httpclient

this.formatter.format(buffer, new NameValuePair("$Version", Integer.toString(version)));
for (int i = 0; i < cookies.length; i++) {
  buffer.append("; ");
origin: commons-httpclient/commons-httpclient

/**
 * 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);
  }
}
origin: commons-httpclient/commons-httpclient

params.add(new NameValuePair(paramName, paramValue));
origin: commons-httpclient/commons-httpclient

private void doFormatCookie2(final Cookie2 cookie, final StringBuffer buffer) {
  String name = cookie.getName();
  String value = cookie.getValue();
  if (value == null) {
    value = "";
  }
  this.formatter.format(buffer, new NameValuePair(name, value));
  // format domain attribute
  if (cookie.getDomain() != null && cookie.isDomainAttributeSpecified()) {
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Domain", cookie.getDomain()));
  }
  // format path attribute
  if ((cookie.getPath() != null) && (cookie.isPathAttributeSpecified())) {
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Path", cookie.getPath()));
  }
  // format port attribute
  if (cookie.isPortAttributeSpecified()) {
    String portValue = "";
    if (!cookie.isPortAttributeBlank()) {
      portValue = createPortAttribute(cookie.getPorts());
    }
    buffer.append("; ");
    this.formatter.format(buffer, new NameValuePair("$Port", portValue));
  }
}

origin: stackoverflow.com

NameValuePair nvp1= new NameValuePair("firstName","fname");
NameValuePair nvp2= new NameValuePair("lastName","lname");
NameValuePair nvp3= new NameValuePair("email","email@email.com");
origin: apache/cloudstack

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
for (Entry<String, String> e : parameters.entrySet()) {
  nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
origin: apache/cloudstack

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
for (Entry<String, String> e : parameters.entrySet()) {
  nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
origin: org.apache.portals.jetspeed-2/jetspeed-portal

protected NameValuePair[] buildPathQueryArgs(String appPath)
{
  if (!appPath.startsWith("/"))
  {
    appPath = "/" + appPath;
  }
  return new NameValuePair[] { new NameValuePair("path", appPath)};
}
origin: org.jenkins-ci/htmlunit

/**
 * {@inheritDoc}
 */
public NameValuePair[] getSubmitKeyValuePairs() {
  String text = getText();
  text = text.replace("\r\n", "\n").replace("\n", "\r\n");
  return new NameValuePair[]{new NameValuePair(getNameAttribute(), text)};
}
origin: otros-systems/otroslogviewer

public Set<String> loggerPatterns() throws IOException {
 final GetMethod method = new GetMethod(getUrl());
 method.setQueryString(new NameValuePair[]{new NameValuePair("o", "loggersConfig")});
 final String content = executeAndGetContent(method);
 final Type type = new TypeToken<Collection<LoggerPatternsResponse>>() {
 }.getType();
 final List<LoggerPatternsResponse> o = new Gson().fromJson(content, type);
 return o.stream().flatMap(patterns -> patterns.getPatterns().stream()).collect(Collectors.toSet());
}
origin: org.jvnet.hudson/htmlunit

/**
 * {@inheritDoc}
 */
public NameValuePair[] getSubmitKeyValuePairs() {
  return new NameValuePair[]{new NameValuePair(getPromptAttribute(), getValue())};
}
origin: stackoverflow.com

// Create client with settings
final WebClient webClient = new WebClient();
webClient.setTimeout(5000);
// Create web request
WebRequest requestSettings = new WebRequest(new URL("http://www.amazon.com/s/ref=nb_sb_noss"), HttpMethod.POST);
// Set the request parameters
requestSettings.setRequestParameters(new ArrayList());
requestSettings.getRequestParameters().add(new NameValuePair("field-keywords", "Doctor Who"));
Page page = webClient.getPage(requestSettings);
page.getWebResponse().getStatusCode();
org.apache.commons.httpclientNameValuePair<init>

Javadoc

Default constructor.

Popular methods of NameValuePair

  • getValue
    Return the current value.
  • getName
    Return the name.
  • setName
    Set the name.
  • setValue
    Set the value.
  • toString
    Get a String representation of this pair.

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • getApplicationContext (Context)
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now