Java JSB Servlets Question and Answers

45. What is session ID?
  A session ID is an unique identification string usually a long, random and alpha numeric string, that is transmitted between the client and the server. Session IDs are usually stored in the cookies, URLs ( in case url rewriting) and hidden fields of Web pages.
 
Your Name Your Email-ID
Your Answer
46. What is session tracking?
  HTTP is stateless protocol and it does not maintain the client state. But there exists a mechanism called "session tracking" which helps the server to maintain the state to track the series requests from the same user across period of time.
 
Your Name Your Email-ID
Your Answer
47. What are Page directives?
 
  • Page directive is used to define page attributes the JSP file. Below is a sample of the same: <%@ page language = "Java" import= "java.rmi.*,java.util.*" session = "true" buffer="12kb" autoFlush="true" errorPage="error.jsp" % >
  • To summarize some of the important page attributes:
  • import: Comma separated list of packages or classes, just like import statements in usual Java code.
  • session: Specifies whether this page can use HTTP session.
  • buffer: If a buffer size is specified (such as "50kb") then output is buffered with a buffer size not less than that value.
  • isThreadSafe: Defines the level of thread safety implemented in the page. If set "true" the JSP engine may send multiple client requests to the page at the same time. If "false" then the JSP engine queues up client requests sent to the page for processing, and processes them one request at a time, in the order they were received. This is the same as implementing the javax.serlvet.SingleThreadModel interface in a servlet.
  • errorPage: Defines a URL to another JSP page, which is invoked if an unchecked runtime exception is thrown. The page implementation catches the instance of the Throwable object and passes it to the error page processing.
 
Your Name Your Email-ID
Your Answer
48. What are include directives?
  The include directive informs the JSP engine to include the content of the resource in the current JSP page. Below is the syntax for include statement.
<%@ include file = "Filename" % >
Below is a code snippet which shows include directive in action
<html >
<head >
<title>Directives in action>
</head >
<%@ include file = "/ companyname.html" %>
<body><h1>Directive in action </h1>
</body >
</html >
 
Your Name Your Email-ID
Your Answer
123456789101112131415


Page 12 of 15