Wednesday, 29 February 2012
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).
Monday, 27 February 2012
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.
Friday, 24 February 2012
Monday, 20 February 2012
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
Friday, 17 February 2012
- 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.
Saturday, 11 February 2012
- HTTP stands for HyperText Transfer Protocol, whereas, HTTPS is HyperText Transfer Protocol Secure.
- HTTP transmits everything as plan text, while HTTPS provides encrypted communication, so that only the recipient can decrypt and read the information. Basically, HTTPS is a combination of HTTP and SSL (Secure Sockets Layer). This SSL is that protocol which encrypts the data.
- HTTP is fast and cheap, where HTTPS is slow and expensive.
- As, HTTPS is safe it’s widely used during payment transactions or any sensitive transactions over the internet. On the other hand, HTTP is used most of the sites over the net, even this blogspot sites also use HTTP.
Friday, 10 February 2012
- HTTP is a stateless protocol. That means, It doesn’t contain any information regarding the client.
- It works as a request-response protocol in the client-side computing model.
- As it’s an Application Layer Protocol within the Framework Internet Protocol Suite, needs a Transfer Layer Protocol (usually Transmission Control Protocol) for data transmission.
- It carries request from Client-side (web browser) to the web server, known as HTTP Request. And again the response from the web-server to the browser, known as HTTP Response.
· HTTP Request means transferring a request form the client side to the server.
· It contains different types of HTTP Request Methods, which are used to indicate the type of the request.
· It has URI which locate the destination.
· It also has Protocol Version (Example: HTTP/1.1)
· Then comes the Request Header, which contains information regarding the client environment like, Accept-Charset, Accept-Encoding, Authorization,etc.
· Then there is a Message Body section, which contains actual information regarding the request.
Thursday, 9 February 2012
HTTP is a stateless protocol. That means it doesn’t contain any information regarding the client, where it’s coming from. So it’s hard for Web Server to know whether it’s a request from a new user or not. This behavior can cause many problems.
Web Server doesn't know if the user requesting this page is the one who is already logged in or if it's a new user. Therefore, to overcome this problem, session tracking is introduced. So session tracking is the process to maintain the important information of a client as a session.
Monday, 6 February 2012
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.
Saturday, 4 February 2012
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.