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

  • Home
  • SEARCH
  • 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 954665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:15:10+00:00 2026-05-16T00:15:10+00:00

I have a URLConnection, that access a web page. URL url = new URL(https://domain);

  • 0

I have a URLConnection, that access a web page.

URL url = new URL("https://domain");
   con = url.openConnection();
   con.setDoOutput(true);

Then i sent some data to the server using con.setRequestProperty()

I get the response cookies fro ma specified field using

String headerValue = con.getHeaderField(6);

I also get the html and parse an image url from there. But here is a problem. I can get this image only by sending cache data back to the server ,when i acces my image.

So i open a new connection

URL url1 = new URL("https://domain/image); 
    URLConnection con1 = url1.openConnection();

I send the cookies back to the server con1.setRequestProperty("Cookie", headerValue);

And finally i try to acces the image using BufferedInputStream and then creating an iamge in a JLabel

BufferedInputStream in = new BufferedInputStream(con1.getInputStream());
       ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
       int c;
       while ((c = in.read()) != -1) {
         byteArrayOut.write(c);
       }


       Image image = Toolkit.getDefaultToolkit().createImage(
               byteArrayOut.toByteArray());

    label.setIcon(new ImageIcon(image));

The problem is this seems to not work. Is it another way to get an file from a server through a URlConnection?
Error code

Server returned HTTP response code: 400 for URL: https://domain/image
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)

Thanks in advance

  • 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-16T00:15:10+00:00Added an answer on May 16, 2026 at 12:15 am

    Found the error. Case closed.
    Used this code to split the cookies string.

    String temp = headerValue.substring(0, (len1-17));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple question: if I use URLConnection.setUseCaches(true) when loading something from web,
For example, I have the java code below: URL u = new URL(http://google.com); URLConnection
I'm a little new to objective-C but have run across a problem that I
I have some resource files that are in the classpath of my web application
I'm performing a GET request: HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setConnectTimeout(CONNECT_TIMEOUT); urlConnection.setReadTimeout(READ_TIMEOUT); urlConnection.connect(); by which
I have a web application which has two servlets that exchange information through context
I have a ViewController.m file with 2 buttons that open a urlConnection, and I
I currently have code for posting data to a login page that works fine.
What InputStream type should be used to handle URLConnection streams that have HTTP Content-Encoding
I am using simple urlconnection like this: url = URL+getClient&uid=+cl_id; URL url = new

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.