Back to Top
Showing posts with label SERVLET. Show all posts
Showing posts with label SERVLET. Show all posts

Sunday, 8 July 2012

J2EE: SERVLET: doGet() vs. doPost()

doGet():

  • protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, java.io.IOException – is a method of Class HttpServlet. It is called by the server (via the service method) to allow a servlet to handle a client's GET request.
  • In doGet(), the client’s request parameters are appended to the URL and sent along with header information.
  • doGet() is not a secured process because the request parameters are clearly visible in the URL.
  • Since request parameters are sent along with header information, so only a limited amount of data should be sent.

Sunday, 8 July 2012 by Anijit Sarkar · 14 Read more »

Thursday, 1 March 2012

J2EE: SERVLET: Class GenericServlet vs Class HttpServlet


·                    It is an abstract class which defines a generic and protocol independent servlet. Here, protocol independent means, by default, it doesn’t contain inherent support for any particular type of protocol, but it can be extended to provide implementation of any protocol.

·                    Class GenericServlet implements Interface Servlet and Interface ServletConfig  and it belongs to javax.servlet package.

·                    It offers simpler version of the servlet life cycle methods init() and destroy() and the methods of ServletConfig. That’s why, it makes writing a servlet easier.

·                    Here, the method service(ServletRequest req, ServletResponse res) is abstract, so the subclasses must override it. And this is also the reason why the GenericServlet is an abstract class.

Thursday, 1 March 2012 by Anijit Sarkar · 3 Read more »

Wednesday, 29 February 2012

J2EE: SERVLET: What is Servlet Interface?


Interface javax.servlet.Servlet is that interface which defines the ServletLife Cycle methods. So, all servlets must implement this interface, either directly or by extending a class which implements this interface. Instead of directly implementing the Servlet Interface, a servlet can also extend Class GenericServlet (which implements Servlet Interface), or can extend HttpServlet Class (which extends the GenericServlet class).


Wednesday, 29 February 2012 by Anijit Sarkar · 6 Read more »

Monday, 27 February 2012

J2EE: SERVLET: What is Servlet?


Servlet:

Servlet is a server-side (runs within a Web server), Java Programming Language Class which interacts with clients via request-response programming model (example, HTTP Request-Response model).

It can respond to any type of request, but, generally, it is used to extend the application hosted by Web Server by providing dynamic web content.

It has build-in threading capability and provides a secure environment for programming.

Monday, 27 February 2012 by Anijit Sarkar · 201 Read more »

Monday, 20 February 2012

J2EE: SERVLET: SERVLET API


   Java Servlet API is that Application Program Interface (API), which defines and describes the contracts between servlets and servers. That means, it contains the set of programs and standard instructions to develop a proper access between a servlet and the server. Servlet API is a part of the official J2EE API. This API contains 2 packages with the extension javax. They are as follows.

·        Package javax.servlet
·        Package javax.servlet.http

Monday, 20 February 2012 by Anijit Sarkar · 43 Read more »

Friday, 17 February 2012

J2EE: SERVLET: What happens to Session if the client intentionally turns off the cookies?


   If client intentionally turns off the cookies, that means, the client chooses not to join the session. In this situation, until the client turns on the cookies, getSession will return a different session on each request, and isNew will always return true.
Anijit Sarkar

Friday, 17 February 2012 by Anijit Sarkar · 1 Read more »

J2EE: SERVLET: Session Tracking in Servlets using Interface HttpSession


  • Session tracking in Servlets is done by using Interface HttpSession. It helps to identify a client throughout many page requests or visiting a website and to store details about that client.
  • Whenever a request arrives, it checks for the preexisting session object, to fetch details of the client from there, else, if its first request from a new client, its simple creates a session object for that client. These session objects are simple java objects.
  • HttpSession contains various methods to handle session object. HttpSession object lives in the server, and it automatically associated with the requester by internal mechanism like cookies or URL-rewriting. 
  • Whenever an application invokes or removes an object from a session, the session checks whether the object implemented the interface HttpSessionBindingListener or not. If yes, the servlet informs the object that it has been bounded to the session, if not, notifies unbound from the session. This alert goes after the binding methods complete.

by Anijit Sarkar · 4 Read more »

Monday, 6 February 2012

J2EE: Web Container vs Web Server vs Application Server

Web Container / Servlet Container / Servlet Engine :
  • In J2EE Architecture, a web container(also known as servlet container or servlet engine), is used to manage the components like servlets, JSP.
  • It provides a runtime environment to the components of J2EE.
  • When ever web server receive a request it forward it to web container which deals with it by instantiating, initializing and invoking Servlets and JSP pages. So,basically it controls the whole life cycle of servlet and JSP. 
  • It is a part of the web server.
  • Example: Apache Tomcat.

Monday, 6 February 2012 by Anijit Sarkar · 124 Read more »

Saturday, 4 February 2012

J2EE: SERVLET: Servlet Life Cycle

  Life cycle of a servlet starts when its first load in the memory space in web server and ends when unloaded from the server memory. we can divide this in 3 steps.


  • Server loads the servlet class.
  • Creates an instance for the servlet class.
  • Server initializes the instance by calling init() method.

Saturday, 4 February 2012 by Anijit Sarkar · 69 Read more »

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar