JSP Interview Questions and Answers Part 11


101.What is JSP Implicts Object?

  • Implicit object are Java objects that implement interfaces in the Servlet and JSP API. This objects are created by the web container.

  • Since these objects are created automatically by the container and are accessed using standard variables, hence they are called implicit objects.

  • The implicit object are passed by the container and inserted into the generated servlet code. They are available only within the jspService method and not in any declaration.

  • Implicit objects are useful while scripting JSP pages.


102.How Many Impicts Object available in JSP?

  • There are nine implicit objects available in JSP below chart shows the implicit object.

  • Application

  • Config

  • Exception

  • Out

  • Page

  • PageContext

  • Request

  • Response

  • Session


103.What is JSP Form Processing?

  • You must have come across a situation where you need to pass some information from your browser to a web server for processing the data or booking some E-Airline tickets online.

  • For passing data from browser to web server, browser uses two method, GET method and POST method.



104.What is Filters?

  • Filters can intercept the request and also control the response all without the servlet knowing, which means that filters can be used without touching the servlets code, filters can be a very powerful tool.

  • Filters are Java components very similar to servlets and JSP that you can use to intercept and process requests before that are sent to the servlet, or to process responses after the servlet has completed, but before the response goes back to the client.

  • The Container decides when to invoke your filters based on the declarations in the web.xml file, the web.xml file maps which filters will be called for which request URL patterns.

  • Below are the thing that can be done with the help of filters

  • Perform security checks (request)

  • Reformat request headers or bodies (request)

  • Audit or log requests (request)

  • Compress the response stream (response), I have an example of this below

  • Append or alter the response stream (response)

  • Create a different response altogether (response)


105.What are CookieS in JSP?

  • Cookies are small bits of textual information that a Web server sends to a browser and that the browser later returns unchanged when visiting the same Web site or domain.

  • By letting the server read information it sent the client previously, the site can provide visitors with a number of conveniences such as presenting the site the way the visitor previously customized it or letting identifiable visitors in without their having to re-enter a password.

  • The servlet sends cookies to the browser by using the HttpServletResponse objects addCookie method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.

  • The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the HttpServletRequest objects getCookies method. Several cookies might have the same name but different path attributes.

  • Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created with this class. This class does not support the cache control defined with HTTP 1.1.


106.What is session Tracking?

  • A session is a conversation between the server and a client. A conversation consists series of continuous request and response.

  • HTTP is a “stateless” protocol which means each time a client retrieves a Web page, the client opens a separate connection to the Web server and the server automatically does not keep any record of previous client request.



107.How Many ways to maintain session between web client and web server?

  • There are following four ways to maintain session between web client and web server:

  • Hidden Fields

  • URL Rewriting

  • Cookies

  • Session Object


108.What is the Use of Page Redirection Method?

  • Page redirection is generally used for moving to new page or location with new url address.

  • sendRedirect() method of response object provide the simple mechanism for redirecting the request to new page.

  • sendRedirect() method redirect the response to another resource. sendRedirect() method actually makes the client(browser) to create a new request to get to the resource. The client can see the new url in the browser.


109.What is JSP Tag Library?

  • The JavaServer Pages Standard Tag Library (JSTL), is a component of the Java EE Web application development platform.

  • It extends the JSP specification for creating better web application by adding a tag library of JSP tags for common tasks, such as XML data processing, conditional execution, database access, loops and internationalization.

  • Using JSTL tags and function on a JSP page logic can be embedded without writing a full Java code directly.

  • According to the function area tags in JSTL can be classified into the different JSTL tag library so that JSTL is exposed through multiple Tag Library Descriptor (TLD) in which each of the TLD have its own namespace, or prefix.


110.How can one Jsp Communicate with Java file.

  • Ans:we have import tag <%@ page import="market.stock.*” %> like this we can import all the java file to our jsp and use them as a regular class another way is servlet can send the instance of the java class to our jsp and we can retrieve that object from the request obj and use it in our page.


Pr.Pg border