Apache Tomcat Web Application Server Interview Questions
1. What is application server clustering?
Answer: An application server cluster consists of a number of application servers loosely coupled on a network. The server cluster or server group is generally distributed over a number of machines or nodes. The important point to note is that the cluster appears as a single server to its clients.
The goals of application server clustering are:
Scalability: should be able to add new servers on the existing node or add new additional nodes to enable the server to handle increasing loads without performance degradation and in a manner transparent to the end-users.
Load balancing: Each server in the cluster should process a fair share of client load, in proportion to its processing power, to avoid overloading of some and underutilization of other server resources. Load distribution should remain balanced even as load changes with time.
High availability: Clients should be able to access the server at almost all times. Server usage should be transparent to hardware and software failures. If a server or node fails, its workload should be moved over to other servers, automatically as fast as possible and the application should continue to run uninterrupted. This method provides a fair degree of application system fault-tolerance. After failure, the entire load should be redistributed equally among working servers of the system.
2. What are the portlet window states and portlet modes?
To offer the user the ability to customize portlets, there are special window states like normal, minimized and maximized. A window state determines how much content should appear in a portlet. Normal will display the portlet s data in the amount of space defined by the portal application, maximized will display only that portlet in the whole window, and minimized may display only one or two lines of text.
determine what actions should be performed on a portlet. There are three standard modes like View, Edit and Help. Optional modes are possible. The Generic Portlet class defines three empty methods do edit(..), doView(..) and doHelp(..). Your subclasses can implement any of these methods.
Furthermore, the portlet can use these states and modes to determine what content it needs to show the user at any given point.
3. On Which Port Does Apache Work?
Answer: Apache server runs on two ports which are Http-port 80 and https-port 443.
4. How do portlets provide customization in addition to window states and portlet modes?
Answer: To provide customization portlets support preferences, which are name/value pairs that can be assigned an initial value and later tailored to other values based on user preference. Preferences are initially defined within the portlet s deployment descriptor file portlet.xml and accessed through the PortletPreferences object, which provides methods to retrieve, change or store preferences. Preferences can also be read-only and also can be verified with validators.
5. 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.
6. How will you create a database connection pool in Tomcat server?
The steps to configure a connection pool:
1) Configure pool in context.xml inside the conf folder of tomcat.
2) Perform a JNDI lookup of the pool and get a connection from the data source.
The JDBC connection pooling page shows how one can create a connection pool in the tomcat server.
7. Why is Tomcat not an application server?
Answer: Application server is a broader term where a host services apart from deploying a JSP/Servlet based application are provided. Tomcat is a web server and not application server. This is because of the fact that Tomcat doesn’t provide services to install/manage EJB and JMS based applications.
8. Explain What Is Tomcat Coyote?
Answer: 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 a request back to the requesting client.
9. How Can One Secure the Websites Host on Apache?
Answer: You can do this by implementing the SSL. You can also consider the integration with a Web Application Firewall or use a cloud-based security provider.
10. How can Apache act a Proxy Server?
Answer: You can use a mod_proxy module to make use of like a proxy server. The mod_proxy module can be utilized to hook up with the backend server like Tomcat, WebLogic, WebSphere, and many others.
11. 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 To?
Answer: 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.
12. Explain When You Can Use. And When You Can Use?
Answer: 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.
13. How to cover server model particulars in HTTP response header?
Answer: Add the next in httpd.conf file and restart the net server
Server Tokens Prod
Server Signature Off
This will cover the model and present Server as “Apache” Only.
14. How to put Log level in Debug mode?
Answer: Often needed when you are troubleshooting the issue and wish to capture more details. You can change the logging level to debug by ensuring the following in httpd.conf file.
15. What’s a difference between Apache Web Server and Apache Tomcat?
Answer: Apache Web is an HTTP server to serve static contents where Tomcat is servlet container to deploy JSP files.
You can always integrate Apache HTTP with Tomcat, however, based on the requirement you need to choose either one. If you need a proper web server, then Apache HTTP else Tomcat for JSP-Servlet Container.
16. Where is Apache web server located in data center location?
Answer: You can explain based on your experience, however, typically for Internet-facing applications, it would be in the Internet DMZ network and for intranet, core network.
17. What is the main difference between and sections?
Answer: Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page
18. How to host files in a different folder and what is Alias directive?
Answer: Yes, this can be achieved by the Alias directive in the main Apache configuration file. Alias directive maps resources in the File system, it takes a URL path and substitutes it with a file or directory path on the system with is set up to redirect.
To use Alias directive, Its the part of mod_alias module of Apache.
The default syntax of the Alias directive is:
Alias /images /var/data/images/
Here in above example, /images URL prefix to the /var/data/images prefix that means clients will query for “and Apache will pick up the “sample-image.png” file from /var/data/images/sample-image.png on the server. It’s also known as URL Mapping.
19. What do you understand by MPM in Apache?
Answer: MPM stands for Multi-Processing Modules, actually, Apache follows some mechanism to accept and complete web server requests.
20. What’s the use of mod_ssl and how SSL works with Apache?
Answer: Mod_ssl package is an Apache module, which allows Apache to establish its connection and transfer all the data in a secure encrypted environment. With the help of SSL certificates, all the Login details and other important secret details get transferred in an encrypted manner over the Internet, which prevents our data from Eavesdropping and IP spoofing.
How SSL works with Apache
Whenever an https request comes, these three steps Apache follows:
Apache generates its private key and converts that private key to.CSR file (Certificate signing request).
Then Apache sends the .csr file to the CA (Certificate Authority).
CA will take the .csr file and convert it to .crt (certificate) and will send that .crt file back to Apache to secure and complete the https connection request.
21. How to deploy struggle or JAVA purposes in Apache?
Answer: I’m afraid, Apache is a Web Server and Java primarily based utility deployment is just not attainable with it. However, you’ll be able to combine Java utility server like WebLogic, WebSphere, JBoss the place you’ll be able to deploy struggle, ear recordsdata.
22. How to make sure the net server is getting began after server reboot? Answer: If operating Linux, then you’ll be able to put a script in /and many others/init.d/ and allow to begin on boot utilizing chkconfig command
Let’s say you create a file referred to as apache and put beneath /and many others/init.d
chkconfig –add apache
chkconfig apache on
if on Windows, then guarantee startup sort is chosen “Automatic”
23. What Is Webservers? Why It Is Used?
Answer: Transaction with HTTP request and the HTTP response is called webserver.
Using the internet listening to 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.
24. 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.
25. What’s the Difference Between Location and Directory Sections?
Answer: The directory section involves the file system objects while location sections have to do with the elements in the web page address bar.
26. Where is Apache net server situated in information heart location?
Answer: You can clarify primarily based on your expertise, nevertheless, sometimes for Internet-facing purposes it will be in the Internet DMZ community and for intranet, core community.
But once more it will differ primarily based on utility/group.
27. What is Document Root?
Answer: DocumentRoot is a location of files that can be accessed by clients within the server. Apache HTTP server in RedHat Enterprise Linux serves files from the /var/www/html/ directory by default based on its configurations.
28. What type of IP is required for Apache Web Server to host our website?
Answer: If we have a DSL connection with a static IP then we can use the Apache webserver to host our website.
29. Can we have two Apache Web servers on a single machine?
Answer: Yes, we can run two different Apache servers at one time on a Linux machine, but the condition for that is they should listen on different ports and we can change the ports with Listen directive of Apache.
30. What do you understand by “DirectoryIndex”?
Answer: Directory Index is the name of the first file which Apache looks for when a request comes from a domain. For example: is requested by the client, so Apache will go the document root of that website and looks for the index file (first file to display).
The default setting of Directory Index is .html index.html index. php, if you have different names of your first file, you need to make the changes in httpd.conf or apache 2. conf for Directory Index value to display that to your client browser.
Directory Index: sets the file that Apache will serve if a directory is requested.
- The index.html.var file (a type-map) is used to deliver content-
negotiated documents. The Multi Views Option can be used for the
same purpose, but it is much slower.
- Directory Index index.html index.html.var index.CGI .exe
31. 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.
32. What is the difference between a Web server and an application server?
Answer: In general, an application server prepares data for a Web server — for example, gathering data from databases, applying relevant business rules, processing security checks, and/or storing the state of a user s session. The term application server may be misleading since the functionality is t limited to applications. Its role is more as retriever and manager of data and processes used by anything running on a Web server. In the coming age of Web services, application servers will probably have an even more important role in managing service-oriented components. One of the reasons for using an application server is to improve performance by offloading tasks from a Web server. When heavy traffic has more users, more transactions, more data, and more security checks then more likely a Web server becomes a bottleneck.
Supports HTTP protocol. When a Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page (static content) or delegates the dynamic response generation to some other program such as CGI scripts or Servlets or JSPs in an application server.
Uses various scalability and fault-tolerance techniques.
Exposes business logic and dynamic content to a client through various protocols such as HTTP, TCP/IP, IIOP, JRMP, etc.
Uses various scalability and fault-tolerance techniques. In addition provides resource pooling, component life cycle management, transaction management, messaging, security, etc.
33. How would you achieve design flexibility in a portal to cater for a different look and feel?
Answer: normal Website designers know the type and amount of the initial content but portal designers have to design the portal to be flexible enough to meet diverse clients and users needs. Design flexibility can be achieved by using CSS (Cascading Style Sheets) to avoid hard coding colors and images into the portal so that customers can easily customize (i.e. modify) the look of their portal.
34. 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.
35. 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.
36. 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.
37. 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.
38. What all 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. The following is a list of services provided by Tomcat:
1) Life cycle Management
2) Handling Web Requests
3) Thread Management
4) Connection pooling
39. Suppose there is a clash between the version of the library being shipped with your application and the library of Tomcat, How will you resolve it?
Answer: There should be only one jar file for a particular library and if there is a clash, you should be using the version of the library provided by the server which can avoid problems arising when deploying the application on client machines.
40. Will you classify Tomcat as a web server or application server?
Ideally speaking, tomcat is neither a web server not application server because of the following points:
a) Tomcat has servlet and JSP engine present in it which is not provided by web servers
b) Tomcat can not run EJB based applications which can be run by application servers.
41. Explain What Is Tomcat Valve? Answer: A tomcat valve- new technology is introduced with Tomcat 4 which enables you to link an instance of a Java class with a specific Catalina container.
42. What instrument do you employ for log evaluation?
Answer: You obtained to talk the reality however to give you a concept you should utilize GoEntry, SumoLogic or few talked about right here.
43. Can I Set Java System Properties Differently For Each Web app? Answer: 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 web app’s context.
44. 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.
45. How Can One Know if the Apache Web Server is Running?
You can use several ways as listed here:
Login to the web server and then grep for the ‘httpd’ process. The function involved is:
- ps –ef |grep httpd
- You can also check your monitoring dashboard for any alerts. Another way is to confirm if your apache IP port can be reached in the current browser.
- The other method to consider is the use of net –help |grep 80 functions. It will notify you if the configured IP and port are listening on the server with net.
46. How to troubleshoot port battle concern?
Answer: netstat could be helpful to troubleshoot the port battle concern. If operating a number of cases on a single server then it will be really helpful to have absolute IP: Port configured in Listen directive.
I hope the above questions and reply enable you to organize for an internet server administrator interview. Good luck and let me know in feedback in case you discover
47. 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.
48. What is Virtual Host in Apache?
Answer: The Virtual Host section contains information like Website name, Document root, Directory Index, Server Admin Email, ErrorLog File location, etc.
You are free to add as many directives you require for your domain, but the two minimal entries for a working website is the Server Name and Document Root. We usually define our Virtual Host section at the bottom of httpd.conf file in Linux machines.
Sample Virtual Host
- Server Admin webmaster@dummy-
- Document Root /www/docs/dummy-
- Server Name dummy-
- Error Log logs/dummy-
- Custom Log logs/dummy-
- host.example.com-access_log common
Server Admin: Its usually the email address of the website owner, where the error or notification can be sent.
Document Root: location where the web files are located in the server(Necessary).
Server Name: Its the domain name which you want to access from your web browser(Necessary).
Error Log: Its the location of the log file where all the domain-related logs are being recorded.
49. 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.