Slide 1
Most trusted JOB oriented professional program
DevOps Certified Professional (DCP)

Take your first step into the world of DevOps with this course, which will help you to learn about the methodologies and tools used to develop, deploy, and operate high-quality software.

Slide 2
DevOps to DevSecOps – Learn the evolution
DevSecOps Certified Professional (DSOCP)

Learn to automate security into a fast-paced DevOps environment using various open-source tools and scripts.

Slide 2
Get certified in the new tech skill to rule the industry
Site Reliability Engineering (SRE) Certified Professional

A method of measuring and achieving reliability through engineering and operations work – developed by Google to manage services.

Slide 2
Master the art of DevOps
Master in DevOps Engineering (MDE)

Get enrolled for the most advanced and only course in the WORLD which can make you an expert and proficient Architect in DevOps, DevSecOps and Site Reliability Engineering (SRE) principles together.

Slide 2
Gain expertise and certified yourself
Azure DevOps Solutions Expert

Learn about the DevOps services available on Azure and how you can use them to make your workflow more efficient.

Slide 3
Learn and get certified
AWS Certified DevOps Professional

Learn about the DevOps services offered by AWS and how you can use them to make your workflow more efficient.

previous arrow
next arrow

Top 50 Apache tomcat interview questions and answers

Spread the Knowledge
Apache Tomcat

1) What is Apache Tomcat?

Apache Tomcat is basically a Web Server and Servlet system which is an open-source (i.e. freely available on the internet) and is created by Apache Software Foundation. It is the server mostly used by Java Developers.

The server is nothing but a computer program that provides service to other computers.

There are basically two types of server:

Application Server
Web Server

Apache Tomcat offers HTTP protocol, which means the user can connect with the server from anywhere by the URL provided and can access the Java application.

This is very easy and simple to install and is compatible with any Operating System.

2) Why do we require Apache Tomcat?

Answer: It is required to run Java Web Applications on the host and server-based systems. It also helps to run JSP and Servlets.

3) What is the name of inbuilt Web Container in Tomcat?

The name of the inbuilt Web Container in Tomcat is Catalina which is present in the bin directory.

Catalina is used for loading all the requests related to HTTP and can instantiate the objects of GET () and POST () methods.

4) What are the types of batch file with the help of which we can Start and Stop Apache Tomcat Server?

There are basically two types of batch files with which we can Start and Stop the Server.

They are as follows:

Startup.bat
Shutdown.bat

5) Which is the vital configuration file that is used in Apache Tomcat?

Answer: The vital configuration file that is used in Apache Tomcat is httpd.conf

6) Mention the configuration files of Catalina.

The configurations files of Catalina include:

XML
Properties
Policy
Tomcat-users.xml

7) What are the vital benefits of Running Tomcat as service?

The benefits of Running Tomcat as service are:

Automatic Startup – If tomcat window service starts up automatically then it would be helpful when we want to start the system remotely.
Security – It allows you to execute under a special account which is protected from the other accounts.
Starting off the server without active user login: So even if there is no active user, the available server can be started.

8) What is the deployment process of web application using the WAR file?

There is a Web apps directory in Tomcat under which all the web components JSP, Servlets, HTML are placed. Hereby putting all the files into a single folder we can compress the files into a single unit which has .WAR extension.

Now, we can easily deploy the web application by putting the WAR file in the Web apps directory. And, when the server starts it extracts all the web components.

9) What are the configured Tomcat Valve’s?

There are basically four configured Tomcat Valves which are mentioned below:

Access Log
Remote Host Filter
Remote Address filter
Request Dumper

10) What do you mean by Tomcat Coyote and what is its use?

Tomcat Coyote is basically an HTTP connector based on HTTP/ 1.1 configuration which accepts and sends the web request to the Tomcat engine and again reverts to the client which makes the request.

11) What are the different ways in which we can secure the websites hosted on Tomcat Server?

Answer: There are multiple ways to do it and some of them are mentioned below:

Implementing SSL
Make use of Cloud-based security provider.
Integrating with Web Application Firewall.

12) How is Apache Tomcat different from Apache Web Server?

Apache Tomcat is used to host the web contents whereas Apache Web server is an HTTP server that is built to serve the static contents.

There is always a possibility to integrate Apache Tomcat and Apache Web Server.

13) Apart from Apache Tomcat, what are the different kinds of Web Servers?

There are many web servers as mentioned below:

LiteSpeed Web Server
GWS Web Server
Microsoft IIS Web Server
Nginx Web Server
Jigsaw Web Server
Sun Java System Web Server
Lighttpd Web Server

14) Which version of Apache have you worked on?

For this, we can say that we have worked on httpd – 2.2.3

15) What will happen if we have added “logLevel Debug” in httpd. conf file?

Adding the logLevel Debug provides you with more information in the error log in order to debug an issue.

16) Can we serve Content out of a directory other than the Document Root directory?

Yes, it is possible to serve the Content out of a directory other than the Document Root directory with the help of “Alias” command.

17) Is there any chance to cache files which are viewed frequently?

Yes, there is a chance to cache files which are viewed frequently by using

Mod_file_cache module.

18) How can we put a restriction to upload files on our web server?

Yes, we can restrict the user to upload files on our web server by using the “LimitRequestBody” directive.

Example: LimitRequestBody 20000

Now I have put a limit of 20000 files, so when this mark is reached then the user will not be able to upload any more files in the server.

19) How can an Apache Service be stopped by its control script?

The Apache Service is controlled using a script called the apachectl.

So, to stop the service, we need to run the below-mentioned commands.

#apachectl stop [for Ubuntu based system]
# /etc/inid.t/httpd.stop [for red hat based system]

20) Apache runs as which user and what is the location of the main configuration file?

Apache runs with a user “nobody” and httpd daemon.

The location of the main configuration file is:

# /etc/httpd/conf/httpd.conf
# /etcapache2.conf

21) 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>

22) 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>

23) How Do You Create Multiple Virtual Hosts?

If you want tomcat to accept requests for different hosts e.g. www.myhostname.com then you must

Create ${catalina.home}/www/appBase , ${catalina.home}/www/deploy, and ${catalina.home}/conf/Catalina/www.myhostname.com
Add a host entry in the server.xml file
Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml
Add any parameters specific to this hosts webapp to this context file
Put your war file in ${catalina.home}/www/deploy
When tomcat starts, it finds the host entry, then looks for any context files and will start any apps with a context.

24) 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.

25) 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//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:

index.html

index.htm

index.jsp 

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

26) 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

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

27) 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>

28) How Do You Create Multiple Virtual Hosts?

If you want tomcat to accept requests for different hosts e.g. www.myhostname.com then you must

Create ${catalina.home}/www/appBase , ${catalina.home}/www/deploy, and ${catalina.home}/conf/Catalina/www.myhostname.com
Add a host entry in the server.xml file
Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml
Add any parameters specific to this hosts webapp to this context file
Put your war file in ${catalina.home}/www/deploy
When tomcat starts, it finds the host entry, then looks for any context files and will start any apps with a context.

29) Explain what is the purpose of NAT protocol?

The purpose of NAT protocol is to hide private IP address from public IP address and give a certain level of security to the organization.

30) Explain The Concepts Of Tomcat Servlet Container.?

Tomcat Servlet Container is a servlet container. The servlets runs in servlet container.
The implementation of Java Servlet and the Java Server Pages is performed by this container.
Provides HTTP web server environment in order to run Java code.
Reduces garbage collection
Native Windows and Unix wrappers for platform integration

31) Can I Set Java System Properties Differently For Each Webapp?

No. If you can edit Tomcat’s startup scripts, you can add “-D” options to Java. But there is no way to add such properties in web.xml or the webapp’s context.

32) How Web Server Handles Multiple Requests For Same Action Class(struts) Concurrently?

Struts or any webserver makes new thread for each new request. so multiple request is served with new request object.

33) Explain When You Can Use . And When You Can Use []?

If you are running a bean property, use the .operator, and if you are executing a map value or an array index, it is preferred to use the [] operator. Although you can use these operators interchangeably.

34) What Is Webservers? Why It Is Used?

Transaction with HTTP request and HTTP response is called webserver.

Using the internet listening the HTTP request and providing the HTTP response is also called webserver.It gives only html output.It will not process business logic .They can provide Http server.They are static.

35) Explain What Is Tomcat Coyote?

Tom coyote is an HTTP connector based on HTTP/ 1.1 specification which receives and transport web requests to the Tomcat engine by listening to a TCP/IP port and sent request back to the requesting client.

36) Mention What Are The Connectors Used In Tomcat?

In Tomcat, two types of connectors are used:

HTTP Connectors: It has many attributes that can be changed to determine exactly how it works and access functions such as redirects and proxy forwarding
AJP Connectors: It works in the same manner as HTTP connectors, but they practice the AJP protocol in place of HTTP. AJP connectors are commonly implemented in Tomcat through the plug-in technology mod_jk.

37) What Is Different Between Webserver And Application Server?

The basic difference between a web server and an application server is Webserver can execute only web applications i,e servlets and JSPs and has only a single container known as Web container which is used to interpret/execute web applications. Application server can execute Enterprise application, i,e (servlets, jsps, and EJBs)

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.

38) 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.

39) Mention With How Many Valves Does Tomcat Configured With?

Four types of valves Tomcat is configured with:

Access Log
Remote Address Filter
Remote Host Filter
Request Dumper

40) Explain What Is Tomcat Valve?

A tomcat valve- a new technology is introduced with Tomcat 4 which enables you to link an instance of a Java class with a specific Catalina container.

41) Can I Set Java System Properties Differently For Each Webapp?

No. If you can edit Tomcat’s startup scripts, you can add “-D” options to Java. But there is no way to add such properties in web.xml or the webapp’s context.

42) How To Communicate Between Two Web Servers In Two Diff Systems?

Answer :

By using plug module

43) Mention What Is The Output Of Select * From Tab?

It displays the default tables in the database.

44) Explain how you can configure Tomcat to work with IIS and NTLM?

You have to follow the standard instructions for when the isapi_redirector.dll

Configure IIS to use “integrated windows security”

Ensure that in the server.xml you have disable tomcat authentication

45) Explain when you can use . and when you can use []?

If you are running a bean property, use the .operator, and if you are executing a map value or an array index, it is preferred to use the [] operator. Although you can use these operators interchangeably.

46) Mention what is the default port for Tomcat?

The default port for Tomcat is 8080. After initialising Tomcat on your local machine, you can verify if Tomcat is running the URL: http://localhost:8080

47) Mention what are the connectors used in Tomcat?

In Tomcat, two types of connectors are used

HTTP Connectors: It has many attributes that can be changed to determine exactly how it works and access functions such as redirects and proxy forwarding
AJP Connectors: It works in the same manner as HTTP connectors, but they practice the AJP protocol in place of HTTP. AJP connectors are commonly implemented in Tomcat through the plug-in technology mod_jk.

48) Explain how running Tomcat as a windows service provides benefits?

Running Tomcat as a windows service provides benefits like

Automatic startup: It is crucial for environment where you may want to remotely re-start a system after maintenance
Server startup without active user login: Tomcat is run oftenly on blade servers that may not even have an active monitor attached to them. Windows services can be started without an active user
Security: Tomcat under window service enables you to run it under a special system account, which is protected from the rest of the user accounts

49) Explain how you can deploy a web application using WAR files?

JSPs, servlets, and their supporting files are placed in the proper subdirectories under the web apps directory in Tomcat. You can make all the files under the web apps directory into one compressed file, which ends with .war file extension. You can execute a web application by placing a WAR file in the webapps directory. When a web server starts executing, it pulls out the WAR file’s contents into the appropriate webapps sub-directories.

50) Explain what is Tomcat Valve?

A tomcat valve- a new technology is introduced with Tomcat 4 which enables you to link an instance of a Java class with a specific Catalina container.

Rajesh Kumar
Latest posts by Rajesh Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x