Best 56 Apache Tomcat Interview Questions And Answers

1. What is Tomcat?

  • Tomcat is a Java Servlet container and web server from the Jakarta project of the Apache software foundation.
  • A web server responds with web pages to requests from client browsers.
  • Web servers can provide dynamic content based on the requests sent by the user.
  • Tomcat is very good at this because it provides both Java servlet and JavaServerPages (JSP) technologies.
  • Tomcat can also be used as a web server for many applications even if free servlet and JSP engine is wanted.
  • It can be used standalone or used behind traditional web servers such as Apache httpd, with the traditional server serving static pages and Tomcat serving dynamic servlet and JSP requests.

Apache Tomcat Interview Questions

2. Difference between apache and apache-tomcat server?

Apache:

Apache mostly serves static content by itself, but there are many add-on modules (some of which come with Apache itself) that let it modify the content and also serve dynamic content written in Perl, PHP, Python, Ruby, or other languages.
Basically Apache is an HTTP Server, serving HTTP.

Apache-Tomcat:
Tomcat is primarily a servlet/JSP container. Its written in Java. It can serve static content too, but its main purpose is to host servlets and JSPs.
JSP files (which are similar to PHP, and older ASP files) are generated into Java code (HttpServlet), which is then compiled to .class files by the server and executed by the Java virtual machine.
Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
Although it is possible to get Tomcat to run Perl scripts and the like, you wouldn’t use Tomcat unless most of your content was Java.
Tomcat is a Servlet and JSP Server serving Java technologies

Note:
The two technologies can be used together through a connector module called mod_jk. This will allow you to use the Apache HTTP server to serve regular static webpages, and the Tomcat Servlet engine to execute servlets.3. What are the directories under the apache-tomcat installation dir?Answer:
conf – Server configuration files (including server.xml)
logs – Log and output files
shared – For classes and resources that must be shared across all web applications
webapps – Automatically loaded web applications
work – Temporary working directories for web applications
temp – Directory used by the JVM for temporary files (java.io.tmpdir)

4. How to know your Apache tomcat version?

root@ubuntu:~# /usr/share/tomcat7/bin/version.sh
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr/lib/jvm/java-1.7.0-openjdk-i386
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Apr 1 2013 08:32:04
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.2.0-105-generic-pae
Architecture: i386
JVM Version: 1.7.0_101-b00
JVM Vendor: Oracle Corporation

5. Where can be set roles,username and password?

/conf/tomcat-users.xml

You might also like:
The VI Editor
Apache Server Interview Questions & Answers
PL/SQL Tutorial Part – 01
Top 25 Java Logical Programs
Abstraction in Java

6. 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.

7. what are the configuratiopn file in tomcat server?

Tomacat XML Configuration Files:
server.xml(TOMCAT-HOME/conf/server.xml)
web.xml (TOMCAT-HOME/conf/web.xml)
tomcat-users.xml (TOMCAT-HOME/conf/tomcat-users.xml)

8. How to change the default(8080) port number?

Go to tomcat>conf folder.
Edit server.xml. (/usr/share/tomcat/conf/server.xml)
Search “Connector port”
Replace “8080” by your port number.
Restart tomcat server.

For example, if you change the port to 1977, you would request the URL

Note: While changing the port number make sure that port is not already in use and port no should be greater than 1024, as ports less than or equal to 1024 require superuser access to bind to.

Apache Tomcat Interview Questions

9. How to start and shutdown to tomcat server?

There are two .sh file in cd $CATALINA_HOME/bin dir or in /usr/share/tomcat7/bin/
./startup.sh
./shutdown.sh

10. How do I enable Server Side Includes (SSI)?

Answer:

Two things have to be done for tomcat to aknowledge SSI scripts:
1. Rename $CATALINA_BASE/server/lib/servlets-ssi.renametojar to $CATALINA_BASE/server/lib/servlets-ssi.jar.
2. Uncomment the section of web.xml found in $CATALINA_BASE/conf/web.xml that deals with SSI. it looks like this when it is uncommented:

ssi

org.apache.catalina.ssi.SSIServlet

buffered 1

debug 0

expires 666

isVirtualWebappRelative 0

Top 50 Selenium Webdriver Interview Questions And Answers Pdf

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:

index.html
index.htm
index.jsp

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.

12. What is the directory structure of a web application deployed on Tomcat?

The typical web application structure which is deployed on tomcat is:

Tomcat-application-structure

The contents of WEB-INF folder shall look like:

web-inf

13. Can we run multiple instances of Tomcat server on single machine? If yes how?

I had posted a blog entry about configuring multiple instances of tomcat on a single machine.

14. Explain what does the MAC stands for?

Answer:

MAC means Medium Access Control

15. Mention what are the Catalina’s Configuration files?

Catalina consists of configuration files are

policy
properties
properties
xml
xml
Tomcat-users.xml
xml

16. How To Communicate Between Two Web Servers In Two Diff Systems?

By using plug module .

it is having two containers:

Web Container(for interpreting/executing servlets and jsps)
EJB container(for executing EJBs).
it can perform operations like load balancing , transaction demarcation etc.

Apache Tomcat Interview Questions

17. ow to communicate between two webservers in two diff systems?

By using plug module .

18. Explain When To Use Ssl With Tomcat?

You would use Tomcat to handle connection, when you are running Tomcat as a stand-alone web server. Tomcat training

19.Does Apache have any limits when it comes to URL aliasing and rewriting?

No, Apache web server has no fixed limit on the total aliases and redirects that may be prompted in the configuration files..

20. Does the installation of Apache HTTP server require SSL or PHP support?

The answer is yes since the installation of Apache requires the support of both the SSL and PHP support.

21. Who is responsible of Tomcat?

The Apache Software Foundation. The Apache Software Foundation is an umbrella organization that looks after a number of Open Source projects.

Jakarta is the group name for the Java-based projects of the Apache Software Foundation.

Tomcat is a Web Server that handles server-side Java (in the form of Servlets and JSPs), and it’s a part of the Apache Jakarta project group. Tomcat is the “reference” implementation of the Servlet and JSP standards – in other words, if it runs under Tomcat, it should run under any compliant Servlet / JSP container.

22. What is web.xml configuration file?

The web.xml file is derived from the Servlet specification, and contains information used to deploy and configure the components of your web applications.

23. What is Coyote?

Coyote is a Connector component for Tomcat that supports the HTTP 1.1 protocol as a web server. This allows Catalina, nominally a Java Servlet or JSP container, to also act as a plain web server that serves local files as HTTP documents.

Coyote listens for incoming connections to the server on a specific TCP port and forwards the request to the Tomcat Engine to process the request and send back a response to the requesting client.
Coyote is the HTTP connector that’s built into Tomcat and provides Tomcat with an interface that browsers can connect to.

Apache Tomcat Interview Questions.

24. What is the engine?

The Engine element represents the entire request processing machinery associated with a particular Catalina Service. It receives and processes all requests from one or more Connectors, and returns the completed response to the Connector for ultimate transmission back to the client.

Exactly one Engine element MUST be nested inside a Service element, following all of the corresponding Connector elements associated with this Service.

25. What is the host?

The Host element represents a virtual host, which is an association of a network name for a server.

26. What is the Context?

The Context element represents a web application, which is run within a particular virtual host. Each web application is based on a Web Application Archive (WAR) file, or a corresponding directory containing the corresponding unpacked contents, as described in the Servlet Specification.

27. What is Tomcat-users.xml configuration file?

It is where the Tomcat users are defined and it is located in the conf folder of the Tomcat server root. company

28. What is Catalina?

Catalina is Tomcat’s servlet container. Catalina implements specifications for servlet and JavaServer Pages. Catalina is the Java Engine (JRE / JVM) that’s built into Tomcat and provides an environment in which Servlets can be run.

29. What is the Service?

A Service element represents the combination of one or more Connector components that share a single Engine component for processing incoming requests. One or more Service elements may be nested inside a Server element.

30. What is a Tomcat cluster?

This component is used to manage large applications. It is used for load balancing and can be achieved through many techniques. Apache Tomcat cluster is used to manage more traffic. It provides multiples instances of the Tomcat server with its content balanced between these instances.

Apache Tomcat Interview Questions

31. What is the Tomcat default port?

The default port for Tomcat is 8080. You can change the default port by editing the file server.xml under the conf folder in the Tomcat installed directory. Change the property Connector port=”8080″ to the desired port and restart Tomcat so the changes can take effect.

32. What do you know about Tomcat history?

Tomcat started off as a servlet reference implementation by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make the project open source and played a key role in its donation by Sun Microsystems to the Apache Software Foundation. The Apache Ant software build automation tool was developed as a side-effect of the creation of Tomcat as an open source project.

33. What is TomEE?

Apache TomEE (pronounced “Tommy”) is the Java Enterprise Edition of Apache Tomcat (Tomcat + Java EE = TomEE) that combines several Java enterprise projects including Apache OpenEJB, Apache OpenWebBeans, Apache OpenJPA, Apache MyFaces and others.

34. Where do you configure a database connection pool in Tomcat server?

The Configure pool is in the context.xml inside the conf folder of tomcat.

35. Name some Tomcat features?

Tomcat 7.x implements the Servlet 3.0 and JSP 2.2 specifications. It requires Java version 1.6. Tomcat 8.x implements the Servlet 3.1 and JSP 2.4 Specifications. Tomcat 8.5.x is intended to replace 8.0.x and includes new features pulled forward from Tomcat 9.0.x. Tomcat 8.5 is designed to run on Java SE 7 and later.

36. What servicesa are provided by Tomcat ?

Tomcat server provides a host of services which are not provided by normal web servers like Apache Web Server. Those are:

Servlet Life cycle
Handle Web Requests
Database connection pooling
Clustering
High availability

37. What is the difference between Tomcat and an Application server ?

Tomcat is a servlet container that supports servlets and the JSP technology. An Application server supports many other Java EE technologies. company

38. What is a Tomcat High availability ?

A high-availability feature has been added to facilitate the scheduling of system upgrades without affecting the live environment. This is done by dispatching live traffic requests to a temporary server on a different port while the main server is upgraded on the main port. It is very useful in handling user requests on high-traffic web applications.

Apache Tomcat Interview Questions

39. What is the Connector ?

A Connector represents an end point in which requests are received.

40. What is a servlet container ?

The servlet container is the component of a web server that interacts with Java servlets. The servlet container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access-rights.

The servlet container handles requests to servlets, JavaServer Pages (JSP) files, and other types of files that include server-side code. The Web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-management tasks.

The servlet container implements the web component contract of the Java EE architecture, specifying a runtime environment for web components that includes security, concurrency, lifecycle management, transaction, deployment, and other services. Tomcat Training

41. What is the servlet container life cycle ?

1 Servlet life cycle
1 Servlet life cycle

A servlet life cycle can be defined as the entire process from its creation till the destruction.

Life cycle steps followed by a servlet

The servlet receives a request from a client through one of its connectors then is initialized by calling the init() method.
The servlet calls service() method to process a client’s request and send the response.
The servlet is terminated by calling the destroy() method.
The servlet is garbage collected by the garbage collector of the JVM.

42. What is a connector and why it is used in Tomcat ?

The Apache Tomcat Connectors project is a part of the Tomcat project and provides web server plug-ins to connect web servers with Tomcat and other back-ends.
The supported web servers are:

The Apache HTTP Server with a plugin named mod_jk.
Microsoft IIS with a plugin named ISAPI redirector.
The iPlanet Web Server with a plugin named NSAPI redirector.

43. What is the server ?

A Server element represents the entire Catalina servlet container. Therefore, it must be the single outermost element in the conf/server.xml configuration file. Its attributes represent the characteristics of the servlet container as a whole.

44. What is the server server.xml configuration file ?

The server.xml file is Tomcat main configuration file, and it is responsible for specifying Tomcat configuration on startup.

45. How to deploy War web applications in Tomcat ?

You can drop the WAR file inside the webapps folder or use the Tomcat manager to deploy War files.

46. Can Tomcat use SSL ?

Yes, you need to make additional configurations to make Tomcat use SSL. In resume you need to do these tasks

Generate Keystore
Add a conector in server.xml
Restart Tomcat

Apache Tomcat Interview Questions

47. What is virtual hosting ?

This is a way of hosting more than one domain names on one server using a single IP address. This way, the single server can share its resources which may include memory, processor cycles among others to ensure its efficient use.

48. What is Document Root ?

DocumentRoot directive is the configuration where you can specify the folder location from where the static files will be served. It’s also called as Web Root.

49. What is a mod_evasive module?

mod_evasive is a third-party module that performs one simple task and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.

50.What are the log files generated by Apache ?

There are two popular log files created;

access.log – all request details with the status code
error.log – capture all the errors within apache or connecting in backend

51. What tool do you use for log analysis ?

You got to speak the truth but to give you an idea you can use GoAccess, SumoLogic or few mentioned here.

52. What is mod_vhost_alias ?

It allows hosting multiple sites on the same server via simpler configurations.

53. what is a difference between Apache and Nginx web server ?

Both are categorized as a Web Server and here are some of the main differences.

Nginx is event-based web server where Apache is process based
Nginx is known for better performance than Apache
Apache supports wide range of OS where Nginx doesn’t support OpenVMS and IBMi
Apache has large number of modules integration with backend application server where Nginx is still catching up
Nginx is lightweight and capturing the market share rapidly. If you are new to Nginx, then you may be interested in checking out my articles on Nginx.

54. What is the difference between Worker and Prefork MPM ?

Both MPMs, Worker and prefork has their own mechanism to work with Apache. It totally depends on you that in which mode you want to start your Apache.
Basic difference between Worker and MPM is in their process of spawning the child process. In the Prefork MPM, a master httpd process is started and this master process starts manages all other child processes to serve client requests. Whereas, In the worker MPM one httpd process is active, and it uses different threads to serve client requests.
Prefork MPM uses multiple child processes with one thread each, where worker MPM uses multiple child processes with many threads each.
Connection handling in the Prefork MPM, each process handles one connection at a time, whereas in the Worker mpm each thread handles one connection at a time.
Memory footprints Prefork MPM Large memory footprints, where Worker has smaller memory footprints.

55. What is the main configuration file of Apache server ?

The Apache Web Server is the most commonly used web server. Before going for any interview involving web servers, make sure to go through these apache interview questions. This way you get an idea of what Apache entails. You can share your thoughts in this article with regards to the apache interview questions and the way answers are provided. Feel free to suggest more issues and solutions for the same to help others learn more about the Apache web server.

56. What do you mean by a valid ServerName directive ?

The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.