1.What is Tomcat?Tomcat is a Java Servlet container and web server from Jakartha project of Apache software foundation. A web server sends web pages as response to the requests sent by the browser client. In addition to the static web pages, dynamic web pages are also sent to the web browsers by the web server. Tomcat is sophisticated in this respect, as it provides both Servlet and JSP technologies. Tomcat provides a good choice as a web server for many web applications and also a free Servlet and JSP engine. Tomcat can be used standalone as well as behind other web servers such as Apache httpd. 2.Explain the concepts of Tomcat Servlet Container.
3.How will you clear the cache of Tomcat server?The tomcat server keeps a copy of compiled servlets and JSP’s present in all deployed web application at the following location. 4.What all services are provided by Tomcat?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:
5.How will you create a database connection pool in Tomcat server?The steps to configure connection pool:
6.What are the steps to enable SSL in web application deployed on Tomcat?Read this excellent tutorial on enabling SSL in web application deployed on tomcat 7.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)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. 8.What is the directory structure of a web application deployed on Tomcat?The typical web application structure which is deployed on tomcat is: - images
- js - src - WEB-INF |- classes |- lib |- web.xml - index.html 9.Will you classify Tomcat as web server or application server?Ideally speaking, tomcat is neither a web server not application server because of the following points:
10.What are the steps to configure clustering in Tomcat server?Apache Tomcat wiki lists down the steps for configuring clustering in the guide at Tomcat server clustering 11.How do you define welcome file list?We can define welcome file list in web.xml deployment descriptor by using the welcome-file-list tag as shown in the following sample code: <welcome-file-list>
The actual welcome file being presented to the user shall be decided from the above list. If index.html is present then it shall be shown. If no index.html file is present in the root folder of web application, then server tries to find a file with the name index.htm and that also fails then it finds index.jsp.
<welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> 12.Why is Tomcat not an application server?Application server is broader term where a host services apart from deploying a JSP/Servlet based application are provided. Tomcat is a web server and not application server. This is because of the fact that Tomcat doesn’t provide services to install/manage EJB and JMS based applications. 13.How do you create multiple virtual hosts?If you want tomcat to accept requests for multiple hosts e.g. www.myhostname.com then you must.
14.Suppose when we are starting startup.bat file of Tomcat server it is not started. DOS window appears for a Second only. What we need do?Your set up might have been not done well. Make sure you have added tomcat root directory path in the CATALINA_HOME environment variable and added the bin path in the path variable. 15.How would you set up tomcat for remote debugging?In windows environment , open up your startup.bat and add to file somewhere in beginning
call “%EXECUTABLE%” jpda start %CMD_LINE_ARGS%
When you are connecting with eclipse, set your debug port at 8001. Now when you start your server , you would see the message Remote debugging started
Make sure you comment out call “%EXECUTABLE%” start %CMD_LINE_ARGS% 16.How do I configure Tomcat to work with IIS and NTLM?Follow the standard instructions for when the isapi_redirector.dll Configure IIS to use “integrated windows security” 1 <Connectorport="8009"enableLookups="false"redirectPort="8443"protocol="AJP/1.3"tomcatAuthentication="false"/>
17.How do I override the default home page loaded by Tomcat?After successfully installing Tomcat, you usually test it by loading http://localhost:8080 . The contents of that page are compiled into the index_jsp servlet. The page even warns against modifying the index.jsp files for this reason. Luckily, it is quite easy to override that page. Inside $TOMCAT_HOME/conf/web.xml there is a section called 18.How do I enable Server Side Includes (SSI)?
1 <servlet>
2 <servlet-name>ssi</servlet-name> 3 <servlet-class> 4 org.apache.catalina.ssi.SSIServlet 5 </servlet-class> 6 <init-param> 7 <param-name>buffered</param-name> 8 <param-value>1</param-value> 9 </init-param> 10 <init-param> 11 <param-name>debug</param-name> 12 <param-value>0</param-value> 13 </init-param> 14 <init-param> 15 <param-name>expires</param-name> 16 <param-value>666</param-value> 17 </init-param> 18 <init-param> 19 <param-name>isVirtualWebappRelative</param-name> 20 <param-value>0</param-value> 21 </init-param> 22 <load-on-startup>4</load-on-startup> 23 </servlet> 19.How do I use DataSources with Tomcat?When developing J2EE web applications, the task of database connection management can be daunting. Best practice involves using a J2EE DataSource to provide connection pooling, but configuring DataSources in web application servers and connecting your application to them is often a cumbersome process and poorly documented. 1 <?xmlversion="1.0"encoding="UTF-8"?>
This example shows how to configure a DataSource for a SQL Server database named mytest located on the development machine. Simply edit the Resource name, driverClassName, username, password, and url to provide values appropriate for your JDBC driver.2 3 <Context> 4 5 <Resourcename="jdbc/WallyDB"auth="Container" 6 type="javax.sql.DataSource"username="wally"password="wally" 7 driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" 8 url="jdbc:sqlserver://localhost;DatabaseName=mytest;SelectMethod=cursor;" 9 maxActive="8" 10 /> 11 12 </Context> Access the DataSource in Your Application From a Servlet Here’s how you might access the data in a servlet: 1 InitialContext ic =newInitialContext();
Notice that, when doing the DataSource lookup, you must prefix the JNDI name of the resource with java:comp/env/
2 DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/WallyDB"); 3 Connection c = ds.getConnection(); 4 ... 5 c.close(); 20.What is Apache Tomcat Server ?Apache Tomcat Server is very lightweight java application in itself an application server from the Apache Software Foundation (AES) that run Java servlets and renders Web pages that include Java Server Page coding. |