Ads 468x60px

Pages

Thursday, 28 June 2012

servlets interview questions


1)What is the difference between ServletContext and ServletConfig?
The ServletConfig gives the information about the servlet initialization parameters. The servlet engine implements the ServletConfig interface in order to pass configuration information to a servlet. The server passes an object that implements the ServletConfig interface to the servlet's init() method. The ServletContext gives information about the container. The ServletContext interface provides information to servlets regarding the environment in which they are running. It also provides standard way for servlets to write events to a log file.

2)What is client side refresh?
The standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet/"> This will refresh the page in the browser automatically and loads the new data every 5 seconds.
3)What is the Max amount of information that can be saved in a Session Object ?
There is no such limit on the amount of information that can be saved in a Session Object.  The only limit is the Session ID length , which should not exceed more than 4K.
4)Why should we go for inter servlet communication?
The three major reasons to use inter servlet communication are: a) Direct servlet manipulation - allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration - requires to communicate with each other by sharing specific information (through method invocation)
5)What are the differences between a session and a cookie?
Session is stored in server but cookie stored in client. Session should work regardless of the settings on the client browser. There is no limit on the amount of data that can be stored on session. But it is limited in cookie. Session can store objects and cookies can store only strings. Cookies are faster than session
6)What is HttpTunneling?
HTTP tunneling is used to encapsulate other protocols within the HTTP or HTTPS protocols. Normally the intranet is blocked by a firewall and the network is exposed to the outer world only through a specific web server port, that listens for only HTTP requests. To use any other protocol, that by passes the firewall, the protocol is embedded in HTTP and send as HttpRequest.
7)How to pass information from JSP to included JSP?
By using <jsp:param> tag.

0 comments:

Post a Comment