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.