Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 493853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:26:38+00:00 2026-05-13T05:26:38+00:00

Probably this is often problem, but I can’t solve it. I need to automaticallly

  • 0

Probably this is often problem, but I can’t solve it.
I need to automaticallly fill out some fields on the web form, which is given from server.
I use Apache HttpClient to make more easy my life)
By now, one can consider my steps to acheive the aim:

    1. I have not certificate to http://trac.edgewall.org/ so I download this software and install locally and at finish I’ll have to create NewTicket.
    2. I locally use Trac without any SSL(SSL tunnel). (It’s not difficult to change my program to be able to use HTTPS).
    3. By now, I can authenticate and perform GET request, but I can’t perform POST request

    4. For instance: I perform GET request to the http://localhost:8000/tracenvir/newticket .
    This (~/newticket) page looks as following:
    http://s04.radikal.ru/i177/0912/cb/d43971cebc02.png
    And as response I have : (part of it)
    “input type=”text” id=”field-summary” name=”field_summary” size=”70″ “

    “textarea id=”field-description” name=”field_description” class=”wikitext” rows=”10″ cols=”68″/textarea”‘
    5. So, I write this:

        int status = 0;
        int cookLength=0;
        Cookie[] cookies = null;

        HttpClient client = new HttpClient();
        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        HttpState initialState = new HttpState();
        client.setState(initialState);

        //**********//
        //**Log in**//
        //**********//

        GetMethod login = new GetMethod("http://localhost:8000/tracenvir/login");
        client.getState().setCredentials(AuthScope.ANY,
                new UsernamePasswordCredentials("rauch", "qwert"));
        login.setDoAuthentication(true);
        System.setProperty("javax.net.ssl.trustStore", "/home/rauch/NetBeansProjects/jssecacerts");

        try {
            status = client.executeMethod(login);

        System.out.println("response code = "+status);
        cookies = client.getState().getCookies();
        cookLength = cookies.length;

        for(int i=0;i (less than) cookLength;i++) {
            System.out.println(cookies[i].toString());
        }
        login.releaseConnection();
        } catch(IOException ex) {
            ex.printStackTrace();
        }

        //*********************//
        //**Create New Ticket**//
        //*********************//

        PostMethod post = new PostMethod("http://localhost:8000/tracenvir/newticket");

        NameValuePair[] data = {
            new NameValuePair("field-summary","second error"),
            new NameValuePair("field-descryption","Some stupid descryption..."),
            new NameValuePair("field-type","defect"),
            new NameValuePair("field-priority","major"),
            new NameValuePair("field-version","1.0"),
            new NameValuePair("field-owner","moscow server"),
            new NameValuePair("submit","create ticket"),
        };


        //post.setRequestBody(data);
        post.addParameters(data);
        post.addRequestHeader("Referer","http://localhost:8000/tracenvir/login");
        for(int i=0;i (less than) cookLength;i++) {
            initialState.addCookie(cookies[i]);
        }
        client.setState(initialState);


        try {
            status = client.executeMethod(post);

        System.out.println("response code = "+status);

        byte[] buf = new byte[10];
        int r=0;
        BufferedInputStream is = new BufferedInputStream(post.getResponseBodyAsStream());

        while((r = is.read(buf)) > 0) {
            System.out.write(buf, 0, r);
        }
        post.releaseConnection();
        } catch(IOException ex) {
            ex.printStackTrace();
        }
    }

And I have this:

    400 Error: Bad Request
    Missing or invalid form token. Do you have cookies enabled?

What’s wrong?

    As response on GET request I get this:

      response code = 200
      trac_auth=38144ec2830678183afebf0b14c51721
      trac_form_token=e9648f17987551b8f97e1953

Probably I nedd change this:

    client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:26:39+00:00Added an answer on May 13, 2026 at 5:26 am

    http://www.google.com/support/toolbar/bin/answer.py?hl=en&answer=47972

    I think above link will help u on this topic. its provide video also.. i hope your query will be solved

    http://www.formautofill.com/

    This site will give you a software which will provide auto form filler. provided by microsoft.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have often pondered this one... its probably an idiot question but here goes.
Sometimes I come across this problem where you have a set of functions that
This is an often used HTML piece on websites. <noscript> Please enable JavaScript or
We are often told that regular expressions are slow and should be avoided whenever
this is a follow up to my recent question ( Code for identifying programming
When I have a method that calls a set of methods that offer strong
I'm coding something at the moment where I'm taking a bunch of values over
Even after years of programming, I'm ashamed to say that I've never really fully
From Don Syme blog ( http://blogs.msdn.com/b/dsyme/archive/2010/01/10/async-and-parallel-design-patterns-in-f-reporting-progress-with-events-plus-twitter-sample.aspx ) I tried to implement a twitter stream
After fighting with different things here and there, I was finally able to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.