1. What is Tomcat?
Answer: 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 are 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.
2. Difference between apache and apache-tomcat server?
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.
Tomcat is primarily a servlet/JSP container. It’s 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
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
web-apps – 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?
Answer: 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
Server version: Apache Tomcat/7.0.26
Server built: Apr 1 2013 08:32:04
Server number: 188.8.131.52
OS Name: Linux
OS Version: 3.2.0-105-generic-page
JVM Version: 1.7.0_101-b00
JVM Vendor: Oracle Corporation
5. Where can be set roles, username, and password?
You might also like:
The VI Editor
Apache Server Interview Questions & Answers
PL/SQL Tutorial Part – 01
6. What Is Default Session Time Out In Tomcat?
Answer: The default session timeout 30 minutes in tomcat and can change in $TOMCAT_HOME/conf/web.xml via modifying below entry.
7. what is the configuration file in tomcat server?
Answer: Tomacat XML Configuration Files:
8. How to change the default(8080) port number?
Answer: Go to the tomcat>conf folder.
Edit server.xml. (https://n8c8a2c6.rocketcdn.me/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. ( python training )
9. How to start and shutdown to tomcat server?
Answer: There are two .sh file in cd $CATALINA_HOME/bin dir or in /usr/share/tomcat7/bin/
10. How do I enable Server Side Includes (SSI)?
Two things have to be done for tomcat to acknowledge 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:
11. How do you define a welcome file list?
Answer: We can define the welcome file list in web.xml deployment descriptor by using the welcome-file-list tag as shown in the following sample code:
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 a 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?
Answer: The typical web application structure which is deployed on tomcat is:
The contents of the WEB-INF folder shall look like:
13. Can we run multiple instances of Tomcat server on a single machine? If yes how?
Answer: I had posted a blog entry about configuring multiple instances of tomcat on a single machine. ( data science training online )
14. Explain what does the MAC stands for?
MAC means Medium Access Control
15. Mention what are Catalina’s Configuration files?
Answer: Catalina consists of configuration files are
16. How To Communicate Between Two Web Servers In Two Diff Systems?
Answer: By using a 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.
17. ow to communicate between two webservers in two diff systems?
Answer: By using a plug module.
18. Explain When To Use Ssl With Tomcat?
Answer: You would use Tomcat to handle connection when you are running Tomcat as a stand-alone web server.
19. Does Apache have any limits when it comes to URL aliasing and rewriting?
Answer: No, Apache web server has no fixed limit on the total aliases and redirects that may be prompted in the configuration files. ( hadoop training online)
20. Does the installation of Apache HTTP server require SSL or PHP support?
Answer: The answer is yes since the installation of Apache requires the support of both the SSL and PHP support.
21. Who is responsible for Tomcat?
Answer: 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 the web.xml configuration file?
Answer: The web.xml file is derived from the Servlet specification and contains information used to deploy and configure the components of your web applications. ( data science training online )
23. What is Coyote?
Answer: 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.
24. What is the engine?
Answer: 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. ( devops training online )
25. What is the host?
Answer: The Host element represents a virtual host, which is an association of a network name for a server.
26. What is the Context?
Answer: 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?
Answer: 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?
Answer: 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 Service?
Answer: 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?
Answer: 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.
31. What is the Tomcat default port?
Answer: 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?
Answer: 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 builds automation tool was developed as a side-effect of the creation of Tomcat as an open source project.
33. What is TomEE?
Answer: 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?
Answer: The Configure pool is in the context.xml inside the conf folder of tomcat.
35. Name some Tomcat features?
Answer: 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 services are provided by Tomcat?
Answer: 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
37. What is the difference between Tomcat and an Application server?
Answer: Tomcat is a servlet container that supports servlets and JSP technology. An Application server supports many other Java EE technologies. company
38. What is a Tomcat High availability?
Answer: 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.
39. What is the Connector?
Answer: A Connector represents an endpoint in which requests are received.
40. What is a servlet container?
Answer: 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?
Answer: 1 Servlet life cycle
1 Servlet life cycle
A servlet life cycle can be defined as the entire process from its creation until the destruction.
Life cycle steps followed by a servile
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?
Answer: 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?
Answer: 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?
Answer: The server.xml file is Tomcat main configuration file, and it is responsible for specifying the Tomcat configuration on startup.
45. How to deploy War web applications in Tomcat?
Answer: You can drop the WAR file inside the web apps folder or use the Tomcat manager to deploy War files. ( tableau online training )
46. Can Tomcat use SSL?
Answer: Yes, you need to make additional configurations to make Tomcat use SSL. In resume, you need to do these tasks
Add a connector in server.xml
47. What is virtual hosting?
Answer: 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?
Answer: 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 WebRoot.
49. What is a mod_evasive module?
Answer: 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?
Answer: 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 the backend.
51. What tool do you use for log analysis?
Answer: 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?
Answer: It allows hosting multiple sites on the same server via simpler configurations.
53. what is a difference between Apache and Nginx web server?
Answer: Both are categorized as a Web Server and here are some of the main differences.
Nginx is an event-based web server where Apache is process based
Nginx is known for better performance than Apache
Apache supports a wide range of OS where Nginx doesn’t support OpenVMS and IBMi
Apache has a 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?
Answer: 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 the Apache server?
Answer: 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 webserver. ( hadoop training online )
56. What do you mean by a valid ServerName directive?
Answer: 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.
All Apache Tomcat Interview Questions
Tomcat VideosVersion: 8.5.28
Free Bundle Access
Course Future Updates