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. : )

Friday, 6 June 2008

I agree.....I really cannot stay put

Have been spending the last few months studying for the Java SCWCD 5.0 exam and I finally did it last Monday and passed "satisfactory"! : P Ok more about this one later once I have received my certificate!!!!!!

Anyway back to the MAIN POINT of this post...so after my exam I had about 1 week+ of rest (lol more like crazily indulging myself with "endless entertainment" and a lovely relaxing trip over the long weekend!!!)

But I really got to ADMIT that "I agree.....I really cannot stay put"!!! Yeah I really do agree that I am person that needs to be continuously ON THE MOVE!!! There were numerous times where I found myself having the feeling of 'wasting time / feel abnormally lazy' when engaging myself to my entertainment activities. I guess this is the POST-EXAM symptom where you feel weird that you are not reading / studying for something!!! However, further signs have showed that even though I am enjoying the entertainment (with no studying), my brain is always constantly moving, thinking up ideas on the next 'big successful goal I should aim towards', any tasks I need to do urgently, any that needs to be done soon!!! @.@ yip my brain just have to keep running all the time! haha : P (i guess this is where my motivation comes from)

Yes, I guess I truly am a person who is constantly moving, unable to stay put, both physically (as my friends said so) and mentally (see above : O)!