コード例 #1
0
ファイル: WebsiteLogin.java プロジェクト: simster/ZE_OG41
  public static void login() throws Exception {

    // Dem Client den Benutzernamen und das Kennwort übergeben
    HttpClient client = new HttpClient();
    client.getParams().setParameter("vb_login_username", "Programmierklasse");
    client.getParams().setParameter("vb_login_password", "987654");

    // Text von der Forumseite abholen
    GetMethod method =
        new GetMethod(
            "http://forum.operationgamma41.de/showthread.php?1228-Erfassung-der-Moderationszeiten-!");
    try {
      client.executeMethod(method);
      Cookie[] cookies = client.getState().getCookies();
      for (int i = 0; i < cookies.length; i++) {
        Cookie cookie = cookies[i];
        System.err.println(
            "Cookie: "
                + cookie.getName()
                + ", Value: "
                + cookie.getValue()
                + ", IsPersistent?: "
                + cookie.isPersistent()
                + ", Expiry Date: "
                + cookie.getExpiryDate()
                + ", Comment: "
                + cookie.getComment());
      }
      client.executeMethod(method);
    } catch (Exception e) {
      System.err.println(e);
    } finally {
      method.releaseConnection();
    }
  }
コード例 #2
0
 private void logCookie(Cookie cookie) {
   Log_OC.d(TAG, "Cookie name: " + cookie.getName());
   Log_OC.d(TAG, "       value: " + cookie.getValue());
   Log_OC.d(TAG, "       domain: " + cookie.getDomain());
   Log_OC.d(TAG, "       path: " + cookie.getPath());
   Log_OC.d(TAG, "       version: " + cookie.getVersion());
   Log_OC.d(
       TAG,
       "       expiryDate: "
           + (cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
   Log_OC.d(TAG, "       comment: " + cookie.getComment());
   Log_OC.d(TAG, "       secure: " + cookie.getSecure());
 }