Force HTTP Status Code form Apache Web Server

I had strange problem where in i have to force an HTTP Status Code from Apache Web Server. I tried using PHP to return the header having HTTP status code but even that was showing HTTP 200 OK status inside HTTP Headers. I started debugging this and found that the way Apache Web Server works it will accept the HTTP status code received from PHP and will redirect the request to ErrorDocument inside Apache Web Server. After much googling i found that we can force an HTTP Status code for particular directory/file using .htaccess files.
Continue reading

Convert HashMap Keys to String Array in Java

I was working with HashMap and i wanted to convert all the keys inside the HashMap to array of String. So i tried casting the Object to String since Object is the class from where String is derived. But i got class cast exception. Started looking on what is the issue and found that you cannot directly cast the Object[] to String[]. You have to manually iterate through and create String[] array.
Continue reading