Java JSB Servlets Question and Answers

21. What is the difference between JavaBeans and taglib directives?
  • JavaBeans and taglib fundamentals were introduced for reusability. But following are the major difference between them.
  • Taglib are for generating presentation elements while JavaBeans are good for storing information and state.
  • Use custom tags to implement actions and JavaBeans to present information.
Your Name Your Email-ID
Your Answer
22. What are the different scopes an object can have in a JSP page?
  There are four scope which an object can have in a JSP page.
  • Page Scope: Objects with page scope are accessible only within the page. Data is only valid for the current response. Once the response is sent back to the browser after that data is no more valid. Even if request is passed from one page to other the data is lost.
  • Request Scope: Objects with request scope are accessible from pages processing the same request in which they were created. Once the container has processed the request data is invalid. Even if the request is forwarded to another page, the data is still available.
  • Session Scope: Objects with session scope are accessible in same session. Session is the time users spend using the application, which ends when they close their browser or when they go another website.
  • Application Scope: Application scope objects are basically global object and accessible to all JSP pages which lie in the same application. This creates a global object that's available to all pages. Application scope variables are typically created and populated when an application starts and then used as read only for the rest of the application.
Your Name Your Email-ID
Your Answer
23. What are the different types of session tracking?
  Mechanisms for session tracking are:
  • Cookies
  • URL rewriting
  • Hidden form fields and
  • SSL sessions
Your Name Your Email-ID
Your Answer
24. What is an HTTPSession Class?
  • HTTPSession Class provides a way to identify a user across multiple requests.
  • The servlet container uses HTTPSession interface to create a session between an HTTP client and an HTTP server.
  • The session lives only for a specified time period, across more than one connection or page request from the user.
Your Name Your Email-ID
Your Answer

Page 6 of 15