Tuesday 22 July 2008

Deep within the night.....a moment of sadness....

I finally stopped writing philosophical stuffs in my last few posts, but unfortunately, here it goes again : O .....it's another one of those random post that tries to be deep but probably does not make too much sense at all.....

Sometimes it's funny, you know during those late night hours when you are lying on bed, getting ready to go to sleep. Random pictures or images emerges from the past. All of a sudden your heart feels heavy. You think about the things you have lost or the things that have changed.....you sighed....and probably while you breathed, a slight pain is aching in your heart.....while the moments and images of the past flashes before your eyes.

It's funny, nothing happened today or of any significance at all that would led up to such thoughts at night. It's funny how these feelings just suddenly pops up, when you least expected and for no reasons at all. Life after all is a funny thing. hehe

I just listened to a song while writing this post, incidentally the "feel" of the song perfectly described the sort of night / mood I was trying to describe. (Luckily for me it's nothing related to the lyrics of the song, but it's sad lyrics tho!):
星期六的深夜 - 王力宏 (for lyrics click here)

Although it seems sad, but I just wanted to capture the feelings I have on the blog here. For the sake of remembrance. Life goes up and down. I'm sure I'll enjoy the up times more if I also remember the down times.

As for those who I've lost, I sincerely do hope you are doing well in whatever you are doing.
For those who I still have a hold to, remember to enjoy the present as each second flies past you, because I won't take anything for granted, including all usssss out there. : )

Wednesday 16 July 2008

IE "Friendly" Error Pages

A few days ago, I was trying to create a small error page for 404 error for testing. The funny thing was the page showed up in Firefox but NOT in IE. I was pretty sure I edited the section of my web.xml properly (yes I'm sure I remembered how to do it correction from my SCWCD!!!). I was VERY VERY CONFUSED!!! : (

Luckily one of my colleagues came across this problem before. Apparently on IE5 and IE6 if a 404 error is thrown and the error page is LESS THAN 512 bytes...IE will try to be smart and use it's OWN "friendly" error page! -.- Wait...this does happen on IE7 too...because I was using IE7!!! (And IE will be smart for any error codes I think...not just 404).

The resolution of this is very simple (yet lame), I increased the size of my error page using a comment block. Note, if the error page is a JSP file, you MUST USE HTML comment block to make this work. If you use JSP comment, IE will not recgonise it as increasing the size of the file.

For the official detail about this "feature":
http://support.microsoft.com/kb/294807

Thursday 3 July 2008

Tomcat Root Context and Blank Page

Prelude:
Arggh have been bad and not updating the blog (while I have been busy with UK visa application...more abt that later...as well as taking on a new project at work recently). So there have been a lot of learning done over the past month or so! Anyway let me document one of my great (and painful) discovery that I have made during work over the past week or so!!! : O


Tomcat and its Root Context:
For the past few weeks or so I have been moved into a new project at work where I get to work with new technologies and some really talented senior people!!! It's exciting yet scary (coz I know I'll be doing crazy stuffs)!!!

Yip that's right, in fact, over the past weeks I have already got myself involved in the craziness as I had to poke around the SOURCE CODE of Jakarta Tomcat to see how it sets up its exception page!

Anyway after days of investigation I finally found out the why a root context is important!!!
  • With a Root Context:
    A Root Context is the context that Tomcat serves when you type in http://localhost:8080/ (assuming tomcat is setup to use port 8080), i.e. context name is an empty String "".

    If you have a root context, not only will tomcat return the 'welcome page' when http://localhost:8080/ is requested. Also, if you request for a non-existing context e.g. http://localhost:8080/foobar, it will return you with a tomcat 404 exception page.

  • Without a Root Context:
    However, if the tomcat server DOES NOT have a root context, the result is that not only will you get a blank page returned if you type in http://localhost:8080/. You will also get a blank page if you request for a non-existing context.
Now I finally realise the importance of having a root context. Not only does it affect the pages that get returned to the user but also if you want server-wide behaviour, you will need to edit the deployment descriptor (web.xml) inside the root context. For example, if you want all 404 exception to be redirected to an error page, you will need to define the tag inside the root context's web.xml. : )