Tomcat Interview Questions & Answers


Q: – What is Tomcat?

Tomcat is a Java Servlet container and web server from Jakartha project of Apache software foundation. A web server sends web pages as response to the requests sent by the browser client. In addition to the static web pages, dynamic web pages are also sent to the web browsers by the web server. Tomcat is sophisticated in this respect, as it provides both Servlet and JSP technologies. Tomcat provides a good choice as a web server for many web applications and also a free Servlet and JSP engine. Tomcat can be used standalone as well as behind other web servers such as Apache httpd.

Q: -I stored a cookie on the browser; why can't I see it?

First, check to make sure you spelled the cookie name correctly. Next, make sure the browser has cookies enabled. Also, if you specified a root path for the cookie, make sure that the JSP or servlet reading the cookie is in that path. Remember, too, that if you don't give the cookie a specific expiration time, the cookie will vanish when the user shuts the browser down.

Q: – Why is a new object created whenever I call jsp:useBean?

You probably forgot to specify a scope for the bean. Remember, the default scope for a bean is page, and all beans with page scope disappear when the page finishes executing.

Q: – When do I use . and when do I use []?

Although you can use these operators interchangeably, it is a good idea to use an operator that indicates the kind of data being accessed. For example, if you are accessing a bean property, use the . operator. If you are accessing a map value or an array index, use the [] operator. There are plenty of times when you break this rule, especially in cases where you want a map to look like it is a bean, you want things to make sense to the next person who reads your code. You may know the types of all the variables, but the next person may not.

Q: – How do I configure Tomcat to work with IIS and NTLM?

Follow the standard instructions for when the isapi_redirector.dll

Configure IIS to use "integrated windows security"

In server.xml, make sure you disable tomcat authentication:

<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" tomcatAuthentication="false" />

Q: – Explain the concepts of Tomcat Servlet Container.

– Tomcat Servlet Container is a servlet container. The servlets runs in servlet container.
– The implementation of Java Servlet and the Java Server Pages is performed by this container.
– Provides HTTP web server environment in order to run Java code.
– Reduces garbage collection
– Native Windows and Unix wrappers for platform integration

Q: – Why do I get a ClassNotFoundException when I try to use the ShoppingCart class?

The JSP engine probably can't see the class in its classpath. Tomcat uses the system classpath, so if ShoppingCart.class is visible somewhere in the system classpath, they should see it.

Q: – 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.

Q: – Can I set Java system properties differently for each webapp?

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 webapp's context.

Submitted By:-Harpreet           Email-ID: –