Apache Tomcat Server Interview Questions and Answers

What is Apache tomcat?

Apache Tomcat is an open-source web server and Servlet/JSP container developed by the Apache Software Foundation. Tomcat implements several Java EE specifications including Java Servlet, Java Server Pages (JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server environment for Java code to run in.

How do I can change the default home page loaded by Tomcat?

We can easily override home page via adding welcome-file-list in application $TOMCAT_HOME/webapps/<deployed-app>/WEB-INF /web.xml file or by editing in container $TOMCAT_HOME/conf/web.xml

In $TOMCAT_HOME/conf/web.xml, it may look like this:
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Request URI refers to a directory, the default servlet looks for a "welcome file" within that directory in following order: index.html, index.htm and index.jsp
If none of these files are found, server renders 404 error.

How to we can change Tomcat default port?

8080 is the default HTTP port that Tomcat attempts to bind to at startup.  To change this, we need to change port in $ TOMCAT_HOME /conf/server.xml, in that we can search 8080 and after getting below statement

<Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000"  redirectPort="8443" />

We can change 8080 to other port like 8081, we need to restart tomcat to take effect. We required changes in URL as http://localhost:8081/.

What is default Session time out in Tomcat?

The default session timeout 30 minutes in tomcat and can change in $TOMCAT_HOME/conf/web.xml via modify below entry
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

Explain directory structure of Tomcat?

Directory structure of Tomcat are
bin - contain startup, shutdown, and other scripts (*.sh for UNIX and *.bat for Windows systems) and some jar files also there.

conf - Server configuration files (including server.xml) and related DTDs. The most important file in here is server.xml. It is the main configuration file for the container.

lib - contains JARs those are used by container and Servlet and JSP application programming interfaces (APIs).

logs - Log and output files.

webapps – deployed web applications reside in it .

work - Temporary working directories for web applications and mostly used during in JSP compilation where JSP is converted to a Java servlet.

temp - Directory used by the JVM for temporary files .

Latest Updates

Fill in the blank

I ________ station before the train arrived.

If I ______ a king, I would help everyone.

Radha___________her daughter for an hour.

Errors Identification

Find out which part of the sentence below has an error and mark the option accourdingly -
Sohan was married in 1990 and have three children.

Find out which part of the sentence below has an error and mark the option accourdingly -
There is no money in the bank in Ram Singh's and Rama's joint account.

Direction

Swapnil start from his home and walked 35 km towards east, after that he turned to his right and walked 20 km. He again turned to his right and walks 35 km. Finally, he turned to his left and walked 20 km and reached his office. How far is his office from his home?

Numbers

How many 2 digit numbers are divisible by 6?

HCF and LCM

Find the smallest square number which is exactly divisible by 3, 5, 15, 18, 20 and 24?

HCF and LCM of two numbers are 82 and 574 respectively. if one of the numbers is 287, find the second number?

Numbers

How many numbers between 1200 to 1500 are multiple of 13?

Find the total number of terms in the series : -3, 1, 5, 9,............., 101 ?

Find the sum of the first 20 terms of the series : 8, -3, 11, -6, 14, -12, 17, -24,....... ?

Series

Find the missing term in the given series - 101, 120, 145, 168, (?), 224

Find the missing term in the given series - 11A13, 17E19, (?), 31O37, 41U43

Find the missing term in the given series - 2,4,8,3,9,27,4,16,(?),5,25,125

Agriculture

Which gas is fixed by Rhizobium bacteria present in the root nodules of a pea plant ?

Chemistry

The formation of sulphurous acid involves ?

The acid present in soft drinks is ?