IGNOU BCA MCA - VIVA Question Answer for JAVA - JSP
JAVA - JSP Selected Question Answer - PART XII
101. What is the structure of the HTTP response ? The HTTP
response consists of three parts:
·
Status Code: describes the status of the response. It can be used to check
if the request has been successfully completed. In case the request failed, the
status code can be used to find out the reason behind the failure. If your
servlet does not return a status code, the success status code, HttpServletResponse.SC_OK,
is returned by default.
·
HTTP Headers: they contain more information about the response. For example,
the headers may specify the date/time after which the response is considered
stale, or the form of encoding used to safely transfer the entity to the user.
·
Body: it contains the content of the response. The body may contain
HTML code, an image, etc. The body consists of the data bytes transmitted in an
HTTP transaction message immediately following the headers.
102. What is a cookie ? What is the difference between session
and cookie ? A cookie is a bit of
information that the Web server sends to the browser. The browser stores the
cookies for each Web server in a local file. In a future request, the browser,
along with the request, sends all stored cookies for that specific Web
server.The differences between session and a cookie are the following:
·
The session should work, regardless of the settings on the
client browser. The client may have chosen to disable cookies. However, the sessions
still work, as the client has no ability to disable them in the server side.
·
The session and cookies also differ in the amount of information
the can store. The HTTP session is capable of storing any Java object, while a
cookie can only store String objects.
103. Which protocol will be used by browser and servlet to
communicate ? The browser communicates with a servlet by using the HTTP
protocol.
104. What is HTTP Tunneling ? HTTP Tunneling is a technique by which,
communications performed using various network protocols are encapsulated using
the HTTP or HTTPS protocols. The HTTP protocol therefore acts as a wrapper for
a channel that the network protocol being tunneled uses to communicate. The
masking of other protocol requests as HTTP requests is HTTP Tunneling.
105. What’s the difference between sendRedirect and forward
methods ? The
sendRedirect method creates a new request, while the forward method just
forwards a request to a new target. The previous request scope objects are not
available after a redirect, because it results in a new request. On the other
hand, the previous request scope objects are available after forwarding.
FInally, in general, the sendRedirect method is considered to be slower compare
to the forward method.
106. What is URL Encoding and URL Decoding ? The URL encoding
procedure is responsible for replacing all the spaces and every other extra
special character of a URL, into their corresponding Hex representation. In
correspondence, URL decoding is the exact opposite procedure.
JSP
107. What is a JSP Page ? A Java Server Page (JSP) is a text
document that contains two types of text: static data and JSP elements. Static
data can be expressed in any text-based format, such as HTML or XML. JSP is a
technology that mixes static content with dynamically-generated content.
108. How are the JSP requests handled ? On the arrival
of a JSP request, the browser first requests a page with a .jsp extension.
Then, the Web server reads the request and using the JSP compiler, the Web
server converts the JSP page into a servlet class. Notice that the JSP file is
compiled only on the first request of the page, or if the JSP file has
changed.The generated servlet class is invoked, in order to handle the
browser’s request. Once the execution of the request is over, the servlet sends
a response back to the client.
109. What are the advantages of JSP ? The advantages
of using the JSP technology are shown below:
·
JSP pages are dynamically compiled into servlets and thus, the
developers can easily make updates to presentation code.
·
JSP pages can be pre-compiled.
·
JSP pages can be easily combined to static templates, including
HTML or XML fragments, with code that generates dynamic content.
·
Developers can offer customized JSP tag libraries that page
authors access using an XML-like syntax.
·
Developers can make logic changes at the component level,
without editing the individual pages that use the application’s logic.
No comments:
Post a Comment