HTTP 400 Bad Request returned only when Java Applet connects to webserver

Posted on 2009-12-22
Last Modified: 2013-11-21

I have a Java applet in my web application for rendering thumbnails. This is always working in most cases. However one of our customer reported that the Applet is not working. They deploy the web application on windows 2008 server. I check the logs and found that when the Java tries to connect to the IIS, I got the following HTTP 400 error:
Data: HTTP/1.1 400 Bad Request\r\nContent-Type: text/html\r\nDate: Thu, 03 Dec 2009 16:17:57 GMT\r\nConnection: close\r\nContent-Length: 20\r\n\r\n<h1>Bad Request</h1>
The url that the Java tried to access to is something like:
Data: GET /App/IrcXmlReq.aspx?Credentials=rxsizb2qnbf5ofddt0ki0zh&What=8&DataSource=CONTENT SERVER

I also tried to visit the url through IE, everything looks OK. I think there's something wrong in the IIS security configuration. Any help or suggestions will be appreciated. Thanks in advance!
private boolean tranSession()
      boolean bRet = false;
      if(sCredentials == null || sTransessionURL == null)
        return false;
      try {
          String tranSessionURLReq = sTransessionURL + "?Credentials=" + sCredentials + "&What=8&DataSource=" + sDataSource;
          URL tranSessionURL = new URL(getCodeBase(), tranSessionURLReq);
          URLConnection con = tranSessionURL.openConnection();
          BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          byte[] buf = new byte[BUF_SIZE];
          int bytesRead = 0;
          while ( (bytesRead = != -1) {
            baos.write(buf, 0, bytesRead);
          String sRet = baos.toString();
          if(sRet.contains("Success") )
            bRet = true;
      catch(Exception e)
      return bRet;

Open in new window

Question by:magicdlf
    LVL 15

    Expert Comment

    I would check out the httperr log.  That might give you some additional details towards  a resolution.  That log file is located at %windir%\system32\logfiles\httperr
    LVL 9

    Author Comment

    I have limited access to the client machine at the moment. I will check the log later. Anything else?
    LVL 6

    Accepted Solution

    it seems you are directly creating url instead use URLEncoder to construct url. Otherwise replace space with % in CONTENT SERVER. Like CONTENT%SERVER to solve current issue.
    LVL 6

    Expert Comment

    or there should be some issue with constructing url
    LVL 9

    Author Comment

    arevuri, you are correct! The java code didn't encode the url. What a terrible mistake!
    Thank you all for your efforts!

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
    I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now