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.
ROOT BEER!
ReplyDeleteHi, I am facing this root context error.
ReplyDeleteMy tomcat server is always returning a blank page. Can you put more light on this topic. How do i get my root context right.
Thanks n advance
Hi Saurabh,
ReplyDeleteSorry for replying so late as I have been quite busy over the past weeks since holiday.
Are you actually running tomcat as an application or are you running it as embedded in your web application?
Because I was actually dealing with an embedded tomcat, so I had to explicitly define a root context. However, if you actually got your tomcat from an installer, I believe it should be pretty trivial and the Tomcat welcome page should be at your root context by default.