Friday, January 4, 2013

Somemore Tomcat Interview Questions and Answers

1) How will you clear the cache of Tomcat server?
Ans: The tomcat server keeps a copy of compiled servlets and JSP’s present in all deployed web application at the following location.
To clear the cache, you just need to delete the folder corresponding to the web application for which you want to clear the cache.
2) What all services are provided by Tomcat?
Ans: Tomcat server provides a host of services which are not provided by normal web servers like Apache Web Server. The following is a list of services provided by Tomcat:
1) Life cycle Management
2) Handling Web Requests
3) Thread Management
4) Connection pooling
5) Clustering
Apart from the above service, you can also tell about the various tomcat components about which not everyone is aware in detail.
3) How will you create a database connection pool in Tomcat server?
Ans: The steps to configure connection pool:
1) Configure pool in context.xml inside conf folder of tomcat.
2) Perform a JNDI lookup of pool and get connection from data source.
The JDBC connection pooling page shows how one can create connection pool in tomcat server.
4) What are the steps to enable SSL in web application deployed on Tomcat?
Ans: Read this excellent tutorial on enabling SSL in web application deployed on tomcat
5) Can we run multiple instances of Tomcat server on single machine? If yes how?
Ans: I had posted a blog entry about configuring multiple instances of tomcat on a single machine.
6) Suppose there is a clash between the version of library being shipped with your application and the library of Tomcat, How will you resolve it? (Take example of Log4J)
Ans: There should be only one jar file for a particular library and if there is a clash, you should be using the version of library provided by the server which can avoid problems arising when deploying the application on client machines.
7) What is the directory structure of a web application deployed on Tomcat?
Ans: The typical web application structure which is deployed on tomcat is:

8) How can one enable Hot Deployment in Tomcat?
Ans: For enabling hot deployment, follow the official guide by Apache at configuring tomcat hot deployment.
9) Will you classify Tomcat as web server or application server?
Ans: Ideally speaking, tomcat is neither a web server not application server because of the following points:
a) Tomcat has servlet and JSP engine present in it which is not provided by web servers
b) Tomcat can not run EJB based applications which can be run by application servers.
10) What are the steps to configure clustering in Tomcat server?
Ans: Apache Tomcat wiki lists down the steps for configuring clustering in the guide at Tomcat server clustering

1 comment: