Top 25 Apache Tomcat Interview Questions
Q1. Explain How Servlet Life Cycles?
The lifestyles-cycle of a standard servlet going for walks on Tomcat:
Tom-cat receives a request from a patron through one in all its connectors
For processing, this request Tomcat maps this request to appropriate
Once the request has been directed to the best servlet, Tomcat verifies that servlet elegance has been loaded. If it is not than Tomcat wraps the servlet into Java Bytecode, that is executable by means of the JVM and paperwork an instance of the servlet
Tomcat initiates the servlet by calling its init The servlet incorporates code that is capable of display Tomcat configuration documents and act thus, as well as declare any sources it might require
Once the servlet has been commenced, Tomcat can call the servlet’s provider approach to proceed the request
Tomcat and the servlet can co-ordinate or talk through the usage of listener classes during the servlet’s lifecycle, which tracks the servlet for an expansion of state adjustments.
To remove the servlet, Tomcat calls the servlets damage technique.
Q2. Explain Directory Structure Of Tomcat?
Directory structure of Tomcat are:
bin - contain startup, shutdown, and other scripts (*.Sh for UNIX and *.Bat for Windows structures) and a few jar documents additionally there.
Conf - Server configuration files (along with server.Xml) and related DTDs. The maximum crucial record in here is server.Xml. It is the principle configuration report for the container.
Lib - contains JARs the ones are utilized by box and Servlet and JSP software programming interfaces (APIs).
Logs - Log and output documents.
Webapps – deployed net packages live in it .
Work - Temporary operating directories for web packages and by and large used at some point of in JSP compilation wherein JSP is transformed to a Java servlet.
Temp - Directory used by the JVM for transient documents .
Q3. Explain How Running Tomcat As A Windows Service Provides Benefits?
Running Tomcat as a home windows carrier gives benefits like:
Automatic startup: It is critical for surroundings where you may want to remotely re-begin a gadget after maintenance
Server startup without energetic user login: Tomcat is run oftenly on blade servers that won't even have an energetic display connected to them. Windows offerings may be began with out an energetic consumer
Security: Tomcat below window carrier enables you to run it beneath a special gadget account, which is protected from the rest of the consumer money owed
Q4. What Is Tomcat?
Tomcat is a Java Servlet field and net server from Jakarta mission of Apache software program basis. A internet server sends net pages as reaction to the requests despatched through the browser customer. In addition to the static internet pages, dynamic internet pages also are sent to the web browsers by means of the internet server. Tomcat is state-of-the-art on this appreciate, as it presents both Servlet and JSP technology. Tomcat provides a great preference as an internet server for plenty web applications and additionally a unfastened Servlet and JSP engine. Tomcat can be used standalone in addition to in the back of other web servers together with Apache httpd.
Q5. How To We Can Change Tomcat Default Port?
8080 is the default HTTP port that Tomcat tries to bind to at startup. To exchange this, we need to change port in $ TOMCAT_HOME /conf/server.Xml, in that we can seek 8080 and after getting under declaration
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
We can exchange 8080 to different port like 8081, we need to restart tomcat to take impact. We required modifications in URL as http://localhost:8081/.
Q6. What Is Webservers? Why It Is Used?
Traction with HTTP request and HTTP reaction is referred to as webserver.
Using the net listening the HTTP request and supplying the HTTP reaction is likewise called webserver.It gives most effective html output.It will not method enterprise common sense .They can offer Http server.They are static.
Q7. Mention What Is The Output Of Select * From Tab?
It presentations the default tables inside the database
Q8. What Is Default Session Time Out In Tomcat?
The default session timeout 30 minutes in tomcat and may exchange in $TOMCAT_HOME/conf/internet.Xml via modify beneath access
<session-config>
<session-timeout>30</session-timeout>
</session-config>
Q9. What Is Different Between Webserver And Application Server?
The fundamental difference between an internet server and an application server is Webserver can execute best web packages i,e servlets and JSPs and has only a single container called Web container that's used to interpret/execute net packages. Application server can execute Enterprise utility, i,e (servlets, jsps, and EJBs)
it's miles having packing containers:
Web Container(for interpreting/executing servlets and jsps)
EJB container(for executing EJBs).
It is able to carry out operations like load balancing , traction demarcation and so on.
Q10. Explain What Is Tomcat Coyote?
Tom coyote is an HTTP connector based totally on HTTP/ 1.1 specification which receives and trport net requests to the Tomcat engine via listening to a TCP/IP port and despatched request lower back to the requesting patron.
Q11. How Do I Can Change The Default Home Page Loaded By Tomcat?
We can effortlessly override domestic web page via adding welcome-record-listing in application $TOMCAT_HOME/webapps//WEB-INF /internet.Xml file or by enhancing in container $TOMCAT_HOME/conf/internet.Xml
In $TOMCAT_HOME/conf/net.Xml, it can appear to be this:
index.Html
index.Htm
index.Jsp
Request URI refers to a listing, the default servlet seems for a "welcome file" inside that listing in following order: index.Html, index.Htm and index.Jsp
If none of these files are located, server renders 404 errors.
Q12. Explain When You Can Use . And When You Can Use []?
If you're jogging a bean property, use the .Operator, and in case you are executing a map price or an array index, it's miles favored to apply the [] operator. Although you can use these operators interchangeably.
Q13. How Web Server Handles Multiple Requests For Same Action Class(struts) Concurrently?
Struts or any webserver makes new thread for each new request. So a couple of request is served with new request item.
Q14. 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 installation could have been not performed nicely.
Make sure you have brought tomcat root directory direction within the CATALINA_HOME environment variable and added the bin path inside the direction variable.
Q15. Explain What Is Tomcat Valve?
A tomcat valve- a new era is brought with Tomcat 4 which permits you to hyperlink an instance of a Java magnificence with a particular Catalina box.
Q16. Mention What Are The Connectors Used In Tomcat?
In Tomcat, two styles of connectors are used:
HTTP Connectors: It has many attributes that can be changed to determine precisely the way it works and access features which includes redirects and proxy forwarding
AJP Connectors: It works within the same manner as HTTP connectors, but they exercise the AJP protocol in place of HTTP. AJP connectors are usually applied in Tomcat thru the plug-in generation mod_jk.
Q17. How To Communicate Between Two Web Servers In Two Diff Systems?
By using plug module .
Q18. Explain What Is Jasper?
Jasper is a Tomcat JSP engine
It parses JSP files to bring together them into JAVA code as servlets
At runtime, Jasper lets in to automatically detect JSP document modifications and recompile them
Q19. Explain What Does The Mac Stands For?
MAC me Medium Access Control
Q20. What Is Apache Tomcat?
Apache Tomcat is an open-source net server and Servlet/JSP field developed by way of the Apache Software Foundation. Tomcat implements numerous Java EE specs which include Java Servlet, Java Server Pages (JSP), Java EL, and WebSocket, and gives a "pure Java" HTTP net server environment for Java code to run in.
Q21. Mention With How Many Valves Does Tomcat Configured With?
Four styles of valves Tomcat is configured with:
Access Log
Remote Address Filter
Remote Host Filter
Request Dumper
Q22. How Do You Create Multiple Virtual Hosts?
If you want tomcat to accept requests for exclusive hosts e.G. Www.Myhostname.Com you then should
Create $catalina.Domestic/www/appBase , $catalina.Domestic/www/set up, and $catalina.Domestic/conf/Catalina/www.Myhostname.Com
Add a bunch access inside the server.Xml report
Create the the subsequent report underneath conf/Catalina/www.Myhostname.Com/ROOT.Xml
Add any parameters specific to this hosts webapp to this context record
Put your struggle file in $catalina.Home/www/installation
When tomcat starts, it reveals the host entry, then looks for any context files and could start any apps with a context.
Q23. Can I Set Java System Properties Differently For Each Webapp?
No. If you may edit Tomcat's startup scripts, you can upload "-D" options to Java. But there's no way to feature such houses in net.Xml or the webapp's context.
Q24. Explain When To Use Ssl With Tomcat?
You could use Tomcat to address connection, while you are running Tomcat as a stand-alone internet server.
Q25. Explain The Concepts Of Tomcat Servlet Container.?
Tomcat Servlet Container is a servlet field. The servlets runs in servlet container.
The implementation of Java Servlet and the Java Server Pages is completed through this field.
Provides HTTP net server environment to be able to run Java code.
Reduces garbage series
Native Windows and Unix wrappers for platform integration
