Apache Tomcat Interview Questions And Answers
Q #1) What is Apache Tomcat?
Answer: 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.
Q #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.
Q #3) What is the default port for Apache Tomcat?
Answer: The default port of Apache Tomcat is port 8080.
After installing Tomcat on your system, click on http://localhost:8080 to validate if Tomcat is running.
Q #4) What is the name of inbuilt Web Container in Tomcat?
Answer: 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.
Q #5) What are the types of batch file with the help of which we can Start and Stop Apache Tomcat Server?
Answer: 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
Q #6) How can we configure Apache Tomcat in Java Eclipse IDE or explain the setup of Apache Tomcat Server?
Answer: It is really very easy and simple to install Apache Tomcat in Eclipse.
The steps are mentioned below:
- Select the Server’s tab at the bottom side of IDE.
- Right-click on blank space or white space.
- Click on New
- Click on Servers
- Choose Tomcat and its next version.
- Click on next
- Select the browse button
- Select the Tomcat root folder
- Click next
- Click Add all
- Click Finish
- Validate the blank area Tomcat must be displaying.
Q #7) How do you Start and Stop Apache Tomcat using services?
Answer:
The services are as follows:
- Services httpd start
- Httpd stop
Q #8) 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
Q #9) How do you find which version of Apache Tomcat web server is running?
Answer: The best way to find the currently running version is stated below:
- Sign in to the web-server
- Go to apache instance and bin folder
- Run “httpd -v” command to get version detail.
Output:
[root@lab sbin] # httpd -v
Server Version: Apache 2.4.18 (Windows)
Server Built: August 2nd, 2018 12.59:00
[root@lab sbin] #
Q #10) Explain the types of connectors used by Apache Tomcat.
Answer: Apache Tomcat basically uses two types of connectors which are as follows:
- HTTP Connectors: HTTP connectors possess attributes which can be modified to determine exactly how it works and access functions such as redirects and proxy forwarding.
- AJP Connectors: AJP connectors follow the AJP protocol in place the of HTTP but work just same as HTTP connectors. They are implemented in Apache Tomcat through the plug-in technology mod_jk.
Q #11) Mention the configuration files of Catalina.
Answer: The configurations files of Catalina include:
- XML
- Properties
- Policy
- Tomcat-users.xml
Q #12) What are the vital benefits of Running Tomcat as service?
Answer: 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.
Q #13) What is the deployment process of web application using the WAR file?
Answer: 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.
Q #14) What is the functionality of Tomcat Valve?
Answer: Tomcat Valve is a new feature which was introduced with Tomcat 4. It is used to link an object of Java class with a specific container of Catalina.
Below image shows working of Tomcat Valve:
Q #15) What are the configured Tomcat Valve’s?
Answer: There are basically four configured Tomcat Valves which are mentioned below:
- Access Log
- Remote Host Filter
- Remote Address filter
- Request Dumper
Q #16) What do you mean by MAC?
Answer: MAC is defined as Medium Access Control.
Q #17) What do you mean by Tomcat Coyote and what is its use?
Answer: 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.
Q #18) What is the result of Select * from the tab?
Answer: This query would display all the tables that are stored in the database.
Q #19) What is the function of Listen in Apache Tomcat?
Answer: Listen plays a vital role for Apache Tomcat and the developers.
Suppose a developer is having multiple IP’s on the server, so if we wish that the Apache should consider only a specified IP then we need to explicitly mention IP and PORT in the Listen Drive.
Example: 10.10.10.20
The below image shows the use of Listen
Q #20) 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.
Q #21) Do Apache Tomcat generate Log files? If yes name them?
Answer: Yes, Apache Tomcat generates Log files.
Basically, there are two important Log Files that are generated by Apache Tomcat.
They are as follows:
- Access.log
- Error.log
Q #22) How do you justify the significance of Virtual Hosting?
Answer: The concept of virtual hosting plays an important role by allowing to host several websites on a single object.
Virtual hosting can be of IP based and Name based.
- Name-Based Virtual Host: It refers that multiple hosts are running on each IP address.
- IP Based Virtual Host: It refers that a different IP address exists for each website served.
Name-Based Virtual Host is widely used everywhere.
Q #23) What are the check or log extent provided by Apache Tomcat?
Answer: There are a plenty of check levels provided and out of which “warn” is the default level.
- Info
- Debug
- Warn
- Notice
- Crit
- Alarm
- Emerg
- Error
Q #24) How is Apache Tomcat different from Apache Web Server?
Answer: 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.
Q #25) Apart from Apache Tomcat, what are the different kinds of Web Servers?
Answer: 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
Q #26) Where are the logs of Apache Tomcat stored?
Answer:
The path is as mentioned below:
Cd/ var/ log/ httpd
Q #27) Which version of Apache have you worked on?
Answer: For this, we can say that we have worked on httpd – 2.2.3
Q #28) What will happen if we have added “logLevel Debug” in httpd. conf file?
Answer: Adding the logLevel Debug provides you with more information in the error log in order to debug an issue.
Q #29) Is it possible to capture the MAC address of the clients who are using your server?
Answer: No, it will not be possible to capture the MAC address of the clients who are using your server.
Q #30) Can we serve Content out of a directory other than the Document Root directory?
Answer: Yes, it is possible to serve the Content out of a directory other than the Document Root directory with the help of “Alias” command.
Q #31) What should we do if we want to know which users are reaching our site?
Answer: We can add the following Log to our activity log format.
%{Referer}
Q #32) Is there any chance to cache files which are viewed frequently?
Answer: Yes, there is a chance to cache files which are viewed frequently by using
Mod_file_cache module.
Q #33) How can we put a restriction to upload files on our web server?
Answer: 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.
Q #34) How can an Apache Service be stopped by its control script?
Answer: 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]
Q #35) What is the significance of status code 403 and 404 in Apache Server?
Answer: The significance of Status code 403 and 404 are mentioned below:
- Status code 403: It refers to a forbidden error like, if a file misses some security context.
- Status code 404: It refers to an error message that it is an HTTP response and the client was not able to communicate with the given server.
Comments
Post a Comment