Pr.Pg Next Pg

Servlet Interview Questions and Answers Part 6

 

51.Describe Servlet collaboration. 

  • Servlet collaboration is all about sharing information among the servlets.

  • Collaborating servlets is to pass the common information that is to be shared directly by one servlet to another through various invocations of the methods.

  • To perform these operations, each servlet need to know the other servlet with which it is collaborated.

  • The collaboration can be done by redirecting a servlet from another or loading the servlets from the ServletContext access methods.

  • This can also be achieved by the methods forward() and include() of RequestDispatcher or by sendRedirect() method. 

 

52.Describe the basics of Servlets. 

  • Servlets are java classes which run on a web server.

  • The results produced by the servlet are viewed on a remote web server. Servlet is a server side component in web applications.

  • The servlets performs the request / response paradigm using the web container.

  • Servlets is the best alternative for CGI.

  • HTTP servlets is advanced and mostly used on current web applications.

  • These servlets responds to HTTP protocol requests that are being sent from a web server and returns web pages.

  • Servlets container creates only one instance for each servlets.

  • The requests are handled by a separate thread.

  • Each thread will invoke doGet or doPost which in turn invokes the service() method where the actual servletís operations are authored. 

 

53.What are the important items in javax.servlets. Explain them. 

  • Servlets : Defines all the methods that a servlets implements. Servlets receives and responds to a request from the web clients. This interface has the methods that are to initialize a servlets, service a request and removal of a servlets from the server.

  • ServletConfig: Servlets configuration is used to send information to a servlets at the time of initializing the servlets. This process is handled by the web container.

  • ServletRequest: Creates an object that is to provide the client requests to the servlets. The servlets container creates the object and sends it to service() method.

  • ServletResponse: Creates an object that is to provide the response to the client by the servlets. The servlets container creates the object and sends it to the service() method. 

 

54.Describe the main purpose of servlets. 

  • A java enabled serverís functionality can be extended by a servlets.

  • Usually a servlets is used to develop web applications in a web server.

  • The servlets are used to create web pages which are called dynamic web pages which mean the content of a web page can change according to the input sent from the web client.

  • Servlets are server independent and platform independent. 

 

 

55.Explain the differences between Jsp and Servlet.

  • The JSP is used mainly for presentation purpose

  • But the Servlets are not used for this purpose only.

  • JSP can be only HttpServlet.

  • HTTP is the only supported protocol in JSP

  • But a servlet is supported by any protocol . e.g HTTP, FTP, SMTP etc

 

56. Name the different ways of session tracking.

  • These ways are given below:

  • Cookies

  • URL rewriting

  • HttpSession,

  • Hidden form fields

57.What are the mechanisms used by a Servlet Container for maintaining session information?

  • For maintaining session information Servlet Container uses:

  • Cookies

  • URL rewriting

  • HTTPS protocol information

 

58.Explain GET and POST.

  • GET: In GET the entire form submission is encapsulated in one URL..

  • The data gets submitted as a part of URL..

  • POST: In POST the data is submitted in the body of HTTP request.

  • The data is not visible on the URL and it is more secure.

 

59. What is session?

  • The session may be said as an object.

  • It is used by a servlet to track a userís interaction.

  • It interacts with the Web application.

  • It works across multiple HTTP requests.The sessions are mainly stored in the server.

 

60.Define the servlet mapping.

  • The servlet mapping is defined as an association between the URL pattern and a servlet.

  • The mapping is used in mapping requests.

  • It maps in the Servlets only.


Pr.Pg border                                              Next Pg

Warning: include_once(bottompad.php) [function.include-once]: failed to open stream: No such file or directory in D:\INETPUB\VHOSTS\cbtsam.com\httpdocs\servlet-tutorials\servlet-tutorials-servlets-interview-part-6.php on line 330

Warning: include_once() [function.include]: Failed opening 'bottompad.php' for inclusion (include_path='.;C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\pear;./includes;./pear') in D:\INETPUB\VHOSTS\cbtsam.com\httpdocs\servlet-tutorials\servlet-tutorials-servlets-interview-part-6.php on line 330

Warning: include_once(rightpad.php) [function.include-once]: failed to open stream: No such file or directory in D:\INETPUB\VHOSTS\cbtsam.com\httpdocs\servlet-tutorials\servlet-tutorials-servlets-interview-part-6.php on line 336

Warning: include_once() [function.include]: Failed opening 'rightpad.php' for inclusion (include_path='.;C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\pear;./includes;./pear') in D:\INETPUB\VHOSTS\cbtsam.com\httpdocs\servlet-tutorials\servlet-tutorials-servlets-interview-part-6.php on line 336