Thursday, February 25, 2010

XP : PC resumes from hibernation on it's own

Had this problem on my XP PC. Trying to be clean and green so I put the PC into hibernation when I'm away for any length of time. (To do this, just press the power switch and then choose the Hibernation option.)

It stayed in hibernation for about 10 minutes and then came out of it on it's own accord.

Mr. Google to the rescue and some research showed the answer here.

The trick is to select the "Only allow management stations to bring the computer out of standby check box" option as described in the article. Problem solved.

Note: The title of the article i.e. "The computer may unexpectedly resume from standby or hibernation and then automatically return to standby or hibernation after two minutes" is somewhat misleading because my PC didn't return to hibernation but the fix still worked.

Enjoy.

Friday, February 12, 2010

Vista : No Audio Output Device is installed

The Compaq laptop with Vista Home Premium that we have always battles to play sounds through the headphones.

Somehow, we manged to disable the laptop sound while trying to get the headphones to work and got the message "No Audio Output Device is installed".

Control panel / Device manager / Sound, video and game controllers shows "High Definition Audio Codec". Tried updating the driver - Nix. Tried checking for new hardware - Nix.

Tried disabling - enabling - Nix.

You need to uninstall the device and then check for new hardware. Vista will find the "new" sound card and re-enable the audio device.

Problem solved.

Enjoy!

Monday, February 08, 2010

Java : Sending a HTTP OPTIONS command

The HTTP OPTIONS command is documented here.

I needed to do this programmatically and thought I would document the code.

 
import java.net.HttpURLConnection;
import java.net.URL;

...

try {
String type = "text/plain;charset=UTF-8";
URL url = new URL("http://xxx/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod("OPTIONS");
conn.setRequestProperty("Content-Type", type);

System.out.println(String.format("HTTP %d: %s",
conn.getResponseCode(), conn.getResponseMessage()));

for(String header : conn.getHeaderFields().keySet() ){
System.out.println(String.format("%s : %s",
header, conn.getHeaderFields().get(header)));
}

String rMessage = conn.getResponseMessage();
System.out.println ("Response " + rMessage);

} catch (Exception e) {
e.printStackTrace();
}
}


Running this against Sun Java System Application Server 9.1 returns:

HTTP 200: OK
X-Powered-By : [Servlet/2.5]
Content-Length : [0]
Allow : [GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS]
null : [HTTP/1.1 200 OK]
Date : [Sun, 07 Feb 2010 19:11:57 GMT]
Server : [Sun Java System Application Server 9.1]
Content-Type : [text/html; charset=iso-8859-1]
Response OK


This sends something like "OPTIONS / HTTP/1.0". There is another version of the command that sends "OPTIONS * HTTP/1.0".

The "*" is actually part of the URI. However, "java.net.HttpURLConnection" has no facility which allows this. Some research suggests that this could be done by using "Apache Commons HttpClient".

Enjoy!