HOME      BLOG       FORUMS      CONTACT       ABOUT

JSP/Servlet interview questions – 5

101. What are the uses of ServletResponse interface?
ServletResponse allows the servlet to set the content length and MIME type of that response. It provides an output stream, ServletOutputStream and a Writer through which the servlet can send data.

102. How HTTP Servlet handles client requests?
An HTTP Servlet handles client requests through its service method. The service method supports standard HTTP client requests by dispatching each request to a method designed to handle that request.

103. Is HTML page a web component?
No. Static HTML pages and applets are not considered as web components by J2EE specification. Even the server-side utility classes are not considered web components.

104. What is the container?
A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading.

105. What is the web container?
Servlet and JSP containers are collectively referred to as Web containers.

106. What is deployment descriptor?
A deployment descriptor is an XML based file which describes a web application’s deployment settings. The name of deployment descriptor of a web application is web.xml.

107. How can I print the stack trace of an exception from a JSP page?
By creating an object of PrintWriter we can print the stack trace in JSP page. Eg:
PrintWriter pw = response.getWriter();
exception.printStackTrace(pw);

108. Do objects stored in a HTTP Session need to be serializable? Or can it store any object?
No, the objects need not to be serializable. We can store any type of objects in session.

109. What is the difference between JspWriter and PrintWriter?
JspWriter is buffered.

110. How can you implement singleton pattern in servlets ?
All servlets are singleton only , if the servlet is not implementing SingleThreadModel.

111. What is the difference between an application server and a web server?
Everything in web server must be achieved programmatically. But application server provides a lot of services like security, transaction , scalability. Application server will be having EJB support where web server don’t have an EJB support.

112. What is servlet exception?
It indicates that there is an exception occurred in the servlet.

113. Can we implement Runnable interface from within our servlet?
Our servlet can implement the Runnable interface.

114. What is a WAR file?
WAR stands for Web Archive. It is a compressed version of your web application. You can use this WAR file to deploy your web application.

115. What is a servlet filter?
Servlet filters are pluggable Web components that allow us to implement pre-processing and post-processing logic in our Web applications.

Share

Tags: , , , ,


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply