Tuesday, April 27, 2010

Charsets, PageEncodings and a JSP page.

I recently had an issue where the prototype HTML page for a JSP displayed OK on my browser but the converted JSP rendered some non-ASCII characters with weird symbols. To top that up, the JQuery animation refused to work.

The fix was simple, I had to re-save the .jsp file by providing a pageEncoding attribute at the top in my (Eclipse) IDE:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
so that the page characters will not be saved with the default JSP encoding of ISO-8859-1.

The charset (contentType="text/html; charset=UTF-8") is the encoding with which the rendered JSP (final output) will be served to a browser while the page encoding (pageEncoding="UTF-8") is the encoding which the JSP compiler will use to understand the contents of the JSP page (saved as a text file) so that it can compile it correctly to a .class file.

Thursday, April 22, 2010

View Status of Network Services

netstat is a simple command line utility for viewing network status available on Windows, Linux and Mac OSX.
To view network status of services using TCP sockets:
netstat -abn -p tcp
for UDP sockets:
netstat -abn -p udp
Tested on both Windows and Mac OSX.

netstat -pant
for TCP Sockets. Tested on a RedHat Linux VM

Saturday, April 3, 2010

Debugging Password-less SSH Authentication

Whenever I need to frequently log into a Amazon EC2 server running Linux, the first thing I usually do is configure password-less login more properly known as public key authentication over SSH.

The steps described here are clear and to the point to help you get started.

The problem I had this time round was due to the folder/file permissions defined for the Linux user (apps) under which I was trying to login with. After some googling, I discovered that you could track SSH authentication attempts by 'tailing' this file: [tail -f] /var/log/secure which on some systems is: [tail -f] /var/log/security and then I noticed the error message --
Apr 3 17:12:36 domU-XX-XX-XX-XX-XX-XX sshd[2626]: Authentication refused: bad ownership or modes for directory /home/apps/.ssh

Rather than 'waste' time solving the permissions problem (after a few attempts I didn't make much progress) I settled with passwordless login as root! I know it's not exactly a good practise but hey the instance is not exactly running mission-critical apps anyway nor does it contain sensitive financial information ....