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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:54:24+00:00 2026-06-03T20:54:24+00:00

I am trying to send a website my username or password using some jar

  • 0

I am trying to send a website my username or password using some jar file from Apache and trying to read everything from the website with the help of my method “loadpage”.

It doesn’t work. After I execute my method “loadpage”. I still get the Streams from the main page, which I don’t need to be logged in. I want to have Streams after i am logged in.

  public static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            httpclient.getCredentialsProvider().setCredentials(
                    new AuthScope("https://justawebsite", 8080),
                    new UsernamePasswordCredentials("username","password"));

            HttpGet httpget = new HttpGet("https://justawebsite");

            System.out.println("executing request" + httpget.getRequestLine());
            HttpResponse response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();

            System.out.println("----------------------------------------");
            System.out.println(response.getStatusLine());
            if (entity != null) {
                System.out.println("Response content length: " + entity.getContentLength());
            }
            EntityUtils.consume(entity);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
    }

I tried it also without the help of some jarfile from Apache.

public  void LogIn(String url1) throws Exception{
        URL url = new URL(url1);

        String userPassword = "username"+":"+"password";
        String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
        //con.setRequestProperty("Cookie", "JSESSIONID="+getSid());

        URLConnection con = url.openConnection();
        //con.connect();
        con.setRequestProperty("Cookie", "JSESSIONID=" + encoding);


        con.connect();

    }

My Method Loadpage: it works because I tried it with some other websites, which don’t need an authentication.

public String loadPage(String url) throws Exception {

    URLConnection con = new URL(url).openConnection();
    StringBuilder buffer = new StringBuilder();

    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line;
    while((line=in.readLine())!= null){
        buffer.append(line);
    }
    in.close();
    return buffer.toString();

}
  • 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-03T20:54:26+00:00Added an answer on June 3, 2026 at 8:54 pm

    Actuualy what i did was correct. I found the Solution just with luck.I don’t know why, but i had to write in.readLine(); one time before the

    in.readLine();
    
    while((line=in.readLine()) != null){
    buffer.append(line);
    }
    in.close()
    

    to get the Streams after i was logged in. If i dont do this line before While.. i get the Streams before i was logged in, allthough i was logged in.

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

Sidebar

Related Questions

I'm trying to setup an email form to send feedback from my website, here
I am trying to send an outlook appointment from an ASP.NET website. I have
I'm trying to load a file using webrequest method. First I need to log
I am trying to send an email via GMail from ASP.Net using the code
I am using java.net.HttpURLConnection to connect to a website and send some data through
I am using node.js and trying send the .html file contains these tags: <meta
I'm trying to upload a PDF file to a website using Hot Banana's content
I'm trying to send an email from my website that I've upgraded from .NET
Im trying to send a custom HTML object from my ASP 2.0 website to
I am trying to send data to DotNetOpenAuth website as described here http://msdn.microsoft.com/en-us/library/debx8sh9.aspx Sender

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.