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 8191475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:55:40+00:00 2026-06-07T03:55:40+00:00

I am trying to emulate this behavior in java curl -u usrname:password http://somewebsite.com/docs/DOC-2264 I

  • 0

I am trying to emulate this behavior in java

curl -u usrname:password http://somewebsite.com/docs/DOC-2264

I am not sure if the auth is NTLM or Basic. I login to the website giving a username and passoword. It’s a form post. Using the curl command above I am able to login and get the content.

To do this in java I did:

    try {
        URL url = new URL("http://somewebsite.com/docs/DOC-2264");
        String authStr ="username:password";
        String encodedAuthStr = Base64.encodeBytes(authStr.getBytes());
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        onnection.setRequestProperty("Authorization", "Basic" + encodedAuthStr);

        InputStream content = (InputStream)connection.getInputStream();
        BufferedReader in   = 
            new BufferedReader (new InputStreamReader (content));
        String line;
        while ((line = in.readLine()) != null) {
            System.out.println(line);
        }           


    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But I only get the login page. Not the actual content.
What am i doing wrong?

  • 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-06-07T03:55:41+00:00Added an answer on June 7, 2026 at 3:55 am
    1. You can see the exact header curl is sending by adding the -v (verbose) option.
    2. The Authorization header needs the authentication type before the base64 encoded username/password. It should look something like this: Authorization: Basic dXNybmFtZTpwYXNzd29yZA==
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to emulate this effect: http://meyerweb.com/eric/css/edge/complexspiral/demo.html on my blog: http://segment6.blogspot.com/ It works, but
I am trying to emulate the menu's in http://www.clydeproperty.com/ I want to hover over
So I am trying to emulate google app's status page: http://www.google.com/appsstatus#hl=en but for backups
I'm trying to emulate the behavior of this drag n drop found here How
I'm getting in trouble. I'm trying to emulate the call Application.Run using Application.DoEvents... this
I am using this jQuery Tooltip plugin . I am trying to emulate the
I'm trying to emulate this graph: If I have a correlation matrix how can
I am trying to emulate StringBuilder behavior in an XSL. Is there a way
I am trying to emulate this simple layout : _______________________________________ |____header___________________________| | | |
I'm trying to emulate the following output (from Marakana.com's excellent Python tutorial : >>>

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.