>> Wednesday, June 15, 2011
Q).What mechanisms are used by servlet Container to maintain the session information?
A).The mechanisms used by a Servlet Container to maintain session information :
a) Cookies
b) URL rewriting
c) Hidden form fields
d) HTTP Sessions.
Q).What are the uses of ServletResponse Interface?
A). ServletResponse interface defines an object to assist a servlet in sending a response to the client.
The servlet container creates a ServletResponse object and passes it as an argument to the servlet's
service method.
To send binary data in a MIME body response, use the ServletOutputStream returned by getOutputStream().
To send character data, use the PrintWriter object returned by getWriter(). To mix binary and text data,
for example, to create a multipart response, use a ServletOutputStream and manage the character sections manually.
Packages that use ServletResponse :
* javax.servlet
* javax.servlet.http
* javax.servlet.jsp.
Q).What is the difference between a session and cookie?
A).Differences between a session and a cookie :
* A cookie is a special piece of data with a bit of associated metadata that an HTTP server includes in an HTTP response.
A session is a series of related HTTP requests and responses that together constitute a single conversation between a client and server.
* Cookies are stored at the client side whereas session exists at the server side.
* A cookie can keep information in the user's browser until deleted, whereas you close your browser you also lose the session.
* Cookies are often used to store a session id, binding the session to the user.
* There is no way to disable sessions from the client browser but cookies.
Q).What is the preintialization of a Servlet?
A).Servlets are loaded and initialized at the first request come to the server and stay loaded until server shuts down.
However there is another way you can initialized your servlet before any request come for that servlet by saying <load-on-startup>1</load-on-startup> in the deployment descriptor.
You can specify <load-on-startup>1</load-on-startup> in between the <servlet></servlet> tag.
Q).What is the difference between ServletConfig and ServletContext?
A).ServletContext and ServletConfig are declared in the deployment descriptor.
ServletConfig is one per servlet and can be accessed only within that specific servlet.
ServletContext is one per web application and accessible to all the servlet in the web application.
A).The mechanisms used by a Servlet Container to maintain session information :
a) Cookies
b) URL rewriting
c) Hidden form fields
d) HTTP Sessions.
Q).What are the uses of ServletResponse Interface?
A). ServletResponse interface defines an object to assist a servlet in sending a response to the client.
The servlet container creates a ServletResponse object and passes it as an argument to the servlet's
service method.
To send binary data in a MIME body response, use the ServletOutputStream returned by getOutputStream().
To send character data, use the PrintWriter object returned by getWriter(). To mix binary and text data,
for example, to create a multipart response, use a ServletOutputStream and manage the character sections manually.
Packages that use ServletResponse :
* javax.servlet
* javax.servlet.http
* javax.servlet.jsp.
Q).What is the difference between a session and cookie?
A).Differences between a session and a cookie :
* A cookie is a special piece of data with a bit of associated metadata that an HTTP server includes in an HTTP response.
A session is a series of related HTTP requests and responses that together constitute a single conversation between a client and server.
* Cookies are stored at the client side whereas session exists at the server side.
* A cookie can keep information in the user's browser until deleted, whereas you close your browser you also lose the session.
* Cookies are often used to store a session id, binding the session to the user.
* There is no way to disable sessions from the client browser but cookies.
Q).What is the preintialization of a Servlet?
A).Servlets are loaded and initialized at the first request come to the server and stay loaded until server shuts down.
However there is another way you can initialized your servlet before any request come for that servlet by saying <load-on-startup>1</load-on-startup> in the deployment descriptor.
You can specify <load-on-startup>1</load-on-startup> in between the <servlet></servlet> tag.
Q).What is the difference between ServletConfig and ServletContext?
A).ServletContext and ServletConfig are declared in the deployment descriptor.
ServletConfig is one per servlet and can be accessed only within that specific servlet.
ServletContext is one per web application and accessible to all the servlet in the web application.
0 comments:
Post a Comment