Logo F2FInterview

Servlet Interview Questions

Q   |   QA

ServletContext: It defines a set of methods that a servlet uses to communicate with its container.
ServletConfig: The object created after a servlet is instantiated and its default constructor is read. It is created to pass initialization information to the servlet.

The session is an object used by a servlet to track a user’s interaction with a Web application across multiple HTTP requests. The session is stored on the server.

Using ServletContext, We can access data from its environment. Servlet context is common to all Servlets so all Servlets share the information through ServeltContext.

We need to use iText. A open source library for java. Please refer sourceforge site for sample servlet examples.

getSession(true) – This method will check whether already a session is existing for the user. If a session is existing, it will return that session object, Otherwise it will create new session object and return taht object.
getSession(false) – This method will check existence of session. If session exists, then it returns the reference of that session object, if not, this methods will return null.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: