Template master

21
Apache Tomcat INTERVIEW QUESTIONS JOBSMATE.COM

Transcript of Template master

Page 1: Template master

Apache TomcatINTERVIEW QUESTIONS

JOBSMATE.COM

Page 2: Template master

JOBSMATE.COM

1. Explain what is Jasper?

Jasper is a Tomcat’s JSP engine

It parses JSP files to compile them into JAVA code as servlets

At runtime, Jasper allows to automatically detect JSP file changes and recompile them

2. Mention what is the output of select * from tab?

It displays the default tables in the database

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

Page 3: Template master

JOBSMATE.COM

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

5. Mention what is the default port for Tomcat?

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

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

Page 4: Template master

JOBSMATE.COM

7. Mention what are the Catalina’s Configuration files?

Catalina consists of configuration files are

• policy

• properties

• properties

• xml

• xml

• Tomcat-users.xml

• xml

Page 5: Template master

JOBSMATE.COM

8. 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 restart a system after maintenance

Server startup without active user login: Tomcat is run often 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

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

Page 6: Template master

JOBSMATE.COM

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

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

12. Mention with how many valves does Tomcat configured with?

Four types of valves Tomcat is configured with

• Access Log

• Remote Address Filter

Page 7: Template master

JOBSMATE.COM

• Remote Host Filter

• Request Dumper

13. Explain how servlet life cycles?

The life-cycle of a typical servlet running on Tomcat

• Tom-cat receives a request from a client through one of its connectors

• For processing, this request Tomcat maps this request to appropriate

• Once the request has been directed to the appropriate servlet, Tomcat verifies that servlet class has been loaded. If it is not than Tomcat wraps the servlet into Java Bytecode, that is executable by the JVM and forms an instance of the servlet

• Tomcat initiates the servlet by calling its init The servlet contains code that is able to screen Tomcat configuration files and act accordingly, as well as declare any resources it might require

• Once the servlet has been started, Tomcat can call the servlet’s service method to proceed the request

Page 8: Template master

JOBSMATE.COM

• Tomcat and the servlet can co-ordinate or communicate through the use of listener classes during the servlet’s lifecycle, which tracks the servlet for a variety of statemchanges.

• To remove the servlet, Tomcat calls the servlets destroy method.

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

15. Explain what does the MAC stands for?

MAC means Medium Access Control

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

Page 9: Template master

JOBSMATE.COM

17. What is webserver? 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.

18. 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 1. Web Container(for interpreting/executing servlets and jsps)

• EJB container(for executing EJBs). it can perform operations like load balancing , transaction demarcation etc etc

Page 10: Template master

JOBSMATE.COM

19. What is tomcat? Can we deploy a servelet in tomcat?

Tomcat is a webserver, Which is support 3 –tier archeticture..

Yes we can

in web.xml

<web-apps>

<servlet-name>

<servlet-class>

20. What is the output of select * from tab?

it displays the default tables in database

Page 11: Template master

JOBSMATE.COM

21. What is the difference between Tomcat 4.1 and Tomcat 5.0?

Web server (for development) that supports servlets 2.3 and JSP 1.2 (Tomcat 4) or servlets 2.4 and JSP 2.0 (Tomcat 5).

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

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

 

Page 12: Template master

JOBSMATE.COM

24. How to communicate between two webservers in two diff systems?

by using plug module

25. How will you clear the cache of Tomcat server?

The tomcat server keeps a copy of compiled servlets and JSP’s present in all deployed web application at the following location.

$Tomcat_ServerworkCatalinalocalhost

To clear the cache, you just need to delete the folder corresponding to the web application for which you want to clear the cache.

26. What all services are provided by Tomcat?

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

 

Page 13: Template master

JOBSMATE.COM

3) Thread Management

4) Connection pooling

5) Clustering

Apart from the above service, you can also tell about the various tomcat components about which not everyone is aware in detail. 

27. How will you create a database connection pool in Tomcat server?

The steps to configure connection pool:

1) Configure pool in context.xml inside conf folder of tomcat.

2) Perform a JNDI lookup of pool and get connection from data source.

The JDBC connection pooling page shows how one can create connection pool in tomcat server.

Page 14: Template master

JOBSMATE.COM

28. Suppose there is a clash between the version of library being shipped with your application and the library of Tomcat, How will you resolve it? (Take example of Log4J)

There should be only one jar file for a particular library and if there is a clash, you should be using the version of library provided by the server which can avoid problems arising when deploying the application on client machines.

30. What is the directory structure of a web application deployed on Tomcat?

The typical web application structure which is deployed on tomcat is:

images

js

src

WEBINF

|classes

Page 15: Template master

JOBSMATE.COM

|lib

|web.

xml

index.

html

31. Will you classify Tomcat as 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.

Page 16: Template master

JOBSMATE.COM

32. What are the steps to configure clustering in Tomcat server?

Apache Tomcat wiki lists down the steps for configuring clustering in the guide at Tomcat server clustering

33. How do you define welcome file list?

We can define welcome file list in web.xml deployment descriptor by using the welcomefilelist tag as shown in the following sample code:

<welcome‐file‐list>

<welcome‐file>index.html</welcome‐file>

<welcome‐file>index.htm</welcome‐file>

<welcome‐file>index.jsp</welcome‐file>

</welcome‐file‐list>

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 web application, then

Page 17: Template master

JOBSMATE.COM

server tries to find a file with the name index.htm and that also fails then it finds index.jsp.

34. Why is Tomcat not an application server?

Application server is 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.

35. How do you create multiple virtual hosts?

If you want tomcat to accept requests for multiple 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 following file under conf/Catalina/www.myhostname.com/ROOT.xml.

Page 18: Template master

JOBSMATE.COM

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

To add more sites just repeat and rinse, all webapps can share the same war file location and appbase.

36. What is Jasper?

Jasper is a program to read the .class files in binary format. This program can generate ASCII files , which can be used along with Jasmin Assembler. Jasper is intended for generating input into a class file browser which can produce the hierarchy of inheritance and composition maps from the .class files.

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

Page 19: Template master

JOBSMATE.COM

38. How would you set up tomcat for remote debugging?

In windows environment , open up your startup.bat and add to file somewhere in beginning

• rem set remote debugger

• set JPDA_ADDRESS=8001

• set JPDA_TRANSPORT=dt_socket

• echo Remote debugging started

Add this to end of your startup.sh file

call “%EXECUTABLE%” jpda start

%CMD_LINE_ARGS%

Make sure you comment out

call “%EXECUTABLE%” start

Page 20: Template master

JOBSMATE.COM

%CMD_LINE_ARGS%

When you are connecting with eclipse, set your debug port at 8001. Now when you start your server , you would see the message Remote debugging started

Page 21: Template master

JOBSMATE.COM

Thank you!