Thanks for all the questions and comments. I'll reply to every one of them in a moment, but first I'd like to use this opportunity to write a brief introduction to this book.
"How Tomcat Works" explains the internal workings of Tomcat. It does not require you to be an expert in Tomcat to understand it. In fact, this book invites you to write Tomcat from scratch. How is it possible? Tomcat is so complex, you might say. That's true, but this book does not try to explain everything in one go.
Chapter 1 starts off with a discussion of Java sockets and shows how to use it to build a simple Java web server that can only display static pages. You know how to read files in Java, don't you? Well, then you can read (static) HTML files. The application is so simple that if you understand how sockets work (explained at the beginning of the chapter), you should be able to understand it. In fact, it only has 3 small classes.
Chapter 2 builds on the application developed in Chapter 1. The application in Chapter 2 is a modified version of the web server in Chapter 1. It adds one function so that the web server can also load and run a servlet. So now the web server has evolved into a servlet container. Because it is so primitive, it can only run very simple servlets. Of course this chapter also explains how the application works. If you have written a servlet before, you know that the javax.servlet.Servlet interface has a lifecycle method named service where you put the code to be executed when the servlet is invoked. This chapter teaches you how to load a servlet class, instantiate it and call its service method. Don't worry about the other 2 lifecycle methods (init and destroy) for now, they will be discussed in the next chapters.
Chapter 3 enhances the application in Chapter 2. You know that the Servlet interface's service method accepts 2 arguments as indicated by its signature:
public void service(HttpServletRequest request, HttpServletResponse response)
The application in Chapter 3 shows how to create the HttpServletRequest and HttpServletResponse objects for every HTTP request that invokes the servlet. (in chapter 2 the application calls the servlet's service method by passing null to its 2 arguments.) Now you see, the application is slightly smarter than the previous one.
And, after Chapter 20, you'll get Tomcat.
By now, I hope you understand the approach I used when writing this book and believe me that you do not need to be a Java expert to follow the book topics. Every Java feature that will be used in an application will be first explained in the corresponding chapter. For example, before discussing the use of JMX in Tomcat, the chapter explains what JMX is and how to use it. Before explaining how Digester is used to parse web.xml files, the chapter explains what Digester is and let you play with a simple application that uses Digester.
Now, is there any use of understanding how Tomcat works?
I received emails that asked me this question soon after Richard Monson-Haefel (the author of Enterprise Java Beans by O'Reilly) mentioned this book in his blog (http://weblogs.java.net/pub/wlg/1372). I would simply say yes.
First of all, by understanding how a servlet container works, you will be able to write better servlet/JSP applications. It will probably answer some of the questions you have been asking too, such as whether or not a container creates one instance or many instances of a servlet, how a servlet container manages sessions, how it creates request and response objects, why we cannot modify the request parameter values, etc.
Also, Tomcat is a real life Java application with such an elegant design. Knowing such an application was designed and built helps any Java programmers and architects. For example, this book shows how Tomcat uses a pool of request objects and at the same time guarantees thread safety. The book also teaches what JMX is and how to use it.
In addition, you will be able to customize Tomcat and build Tomcat components. To demonstrate this point, I have actually written a module for helping Struts programmers develop Struts applications more rapidly. The module reloads your Struts application when your struts-config.xml has changed. Better still, you only need 33 lines of code to write this module. That's right, writing Tomcat custom components can be very easy. You can download the module from the book's website.
Finally, I'd like to invite you to download 6 sample chapters from the book, on www.brainysoftware.com. I hope you enjoy it.
[ September 15, 2004: Message edited by: Budi Kurniawan ]
[ September 15, 2004: Message edited by: Budi Kurniawan ]
First of all I would like to thank Javaranch community that make to talk to some of very good authors.
And most importantly, a great thanks to Budi and other great authors who shares the knowledge in so well way. That makes the life of a developer/researcher easy.
Originally posted by Budi Kurniawan:
To demonstrate this point, I have actually written a module for helping Struts programmers develop Struts applications more rapidly. The module reloads your Struts application when your struts-config.xml has changed. Better still, you only need 33 lines of code to write this module. That's right, writing Tomcat custom components can be very easy. You can download the module from the book's website.
Do u have plan to write a kinda "How Struts Works" in the future? Or are there any other upcoming books from BrainySoftware?
Thanks for being here, clearing our doubts on the book's contents...
I appreciate you taking the time to respond to our questions (and I hope you can help me solve my problem) as well as offering your book for giveaway.
Originally posted by Ko Ko Naing:
"How Struts Works" in the future?
I thought Struts in Action itself was too indepth!I picked up that book and it is turning out to be quite a read.Try that if you have time.
There is too much information out there.
Originally posted by gayathri sridhar:
I thought Struts in Action itself was too indepth!
But if I am not wrong, that book does not discuss about the stuff inside Struts... The book is about "How to use Struts", rather than "How Struts Works"... So I'm just wondering if Budi has some plans to publish such book in the future or not...
Great to talk to you people. Hope u read my posting in the Forum addressed To the Authors.
What to say,... I jus Love Tomcat.
So, thanks for being here and addressing the postings.
Pleased to mee you, digitally, though.....