Thursday, 21 April 2011

J2EE web application


Any web application that runs in the servlet container is called a J2EE web application. The servlet container implements the Servlet and JSP specification. It provides various entry points for handling the request  originating from a web browser. There are three entry points for the browser into the J2EE web application - Servlet, JSP and Filter. You can create your own Servlets by extending the javax.servlet.http.HttpServlet class and implementing the doGet() and doPost() method. You can create JSPs simply by creating a
text file containing JSP markup tags. You can create Filters by implementing the javax.servlet.Filter interface.
The servlet container becomes aware of Servlets and Filters when they are declared in a special file called web.xml 2. A J2EE web application has exactlyone web.xml file. The web  application is deployed into the servlet container by bundling it in zipped archive called Web ARchive – commonly referred to as WAR file.


A servlet is the most basic J2EE web component. It is managed by the servlet container. All servlets  implement the Servlet interface directly or indirectly. In general terms, a servlet is the endpoint for requests adhering to a protocol. However, the Servlet specification mandates implementation for servlets that handle HTTP requests only. But you should know that it is possible to implement the servlet and the container to handle other protocols such as FTP too. When writing Servlets for handling HTTP requests, you generally subclass HttpServlet class. HTTP has six methods of request submission – GET, POST, PUT, HEAD
and DELETE. Of these, GET and POST are the only forms of request submission relevant to application developers. Hence your subclass of HttpServlet should implement two methods – doGet() and doPost() to handle GET and POST respectively. Listing 1.1 shows a doGet() method from a typical Servlet. With this background, let us now dive straight into presentation tier strategies. This coverage of presentation tier strategies will kick start your thought process on how and where Struts fits in the big picture. 

No comments:

Post a Comment