Monday, July 23, 2007

What is the Tomcat server and why do we need it?

A Tomcat server is a container for Java written code. This code can be called servlets or JSP (Java server pages). What the server does is takes this Java code, compiles it into .class files and then displays this to the end user.
What is a Servlet?
A servlet is a piece of Java code which generates a HTML page. This code resides on the server side and depending on the options selected by the user, different parameters are sent to the servlet. The servlet basically has lot of print statements to generate the HTML code dynamically.
JSP is just a easier way to do the same thing what the servlet does. JSP has tags which can be used to embed the Java code inside HTML. The Tomcat server compiles the Java code and makes HTML out of it dynamically. This saves the developer to write lot of print statements to generate the HTML like head, body, title etc.

No comments: