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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:08:22+00:00 2026-05-26T16:08:22+00:00

URL url = new URL(http://soandso.com); String userpassword = username + : + password; conn

  • 0
      URL url = new URL("http://soandso.com");
      String userpassword = username + ":" + password;
      conn = (HttpURLConnection)url.openConnection();
      conn.setDoOutput(true);         
      conn.setRequestMethod("POST");         
      BASE64Encoder enc = new sun.misc.BASE64Encoder();          
      String encodedAuthorization = enc.encode( userpassword.getBytes() );
      conn.setRequestProperty("Authorization", "Basic "+encodedAuthorization);
      OutputStreamWriter writer =new OutputStreamWriter(conn.getOutputStream());
      writer.write("ABC");
      writer.flush ();
      writer.close();
      BufferedReader rd =new BufferedReader(new InputStreamReader(conn.getInputStream()));
      while ((inputLine = rd.readLine()) != null)
      System.out.println(inputLine);

The Output I got follows.

ÜNİTESİ TOPLANTI SALONU

But The actual output is supposed to be — G ÜNİTESİ TOPLANTI SALONU

Can anyone tell me how to fix this?

PS: The code is not from any servlet. Its not a java class.

  • 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-26T16:08:23+00:00Added an answer on May 26, 2026 at 4:08 pm

    This will use the system default character encoding:

    OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
    

    Likewise so will this:

    BufferedReader rd = new BufferedReader(
        new InputStreamReader(conn.getInputStream()));
    

    Using the system default encoding is almost always a bad idea, particularly for networking.

    Which encoding did you want to use for the POST? You should set the Content-Type header to specify which encoding you use, and obviously also specify it in the constructor call to OutputStreamWriter. Likewise you should use the Content-Type of the response to determine which encoding to specify in the InputStreamReader call.

    Generally speaking, it’s things like this that make it worth using a higher-level HTTP library such as Apache HttpClient. That should be able to handle the encoding for you.

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

Sidebar

Related Questions

URL url = new URL(http://twitter.com/statuses/update.xml); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); String cridentials =
URL url = new URL(http://www.example.com/comment); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestMethod(POST); Is connection.setRequestProperty(key,
My Code is String url = http: gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL
URL url = new URL(http://download.thinkbroadband.com/20MB.zip); URLConnection connection = url.openConnection(); File fileThatExists = new File(path);
Here's my code: URL url = new URL(http://www.bing.com/); URLConnection urlConnection = url.openConnection(); BufferedReader in
I have the following scenario: URL u1 = new URL(http://www.yahoo.com/); URL u2 = new
i has a BufferedImage instance: (only a example) BufferedImage image = ImageIO.read(new URL(http://www.google.com/intl/en_ALL/images/srpr/logo1w.png)); now,i
Here's my code: sock = Net::HTTP.new(url.host, url.port) sock.use_ssl = true response = sock.start {|http|
I am passing this url http://new.wadja.com/petty01#bad religion to twitter button and I receive 'url'
I have this code: url = new URL(http://anurl); urlConn = url.openConnection(); dis = 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.