• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

JSP Interview Questions Answers

Question - 61 : - Is there a way I can set the inactivity lease period on a per-session basis?

Answer - 61 : - Typically, a default inactivity lease period for all sessions is set within your JSPengine admin screen or associated properties file. However, if your JSP engine supports the Servlet 2.1 API, you can manage the inactivity lease period on a per-session basis. This is done by invoking the HttpSession.setMaxInactiveInterval() method, right after the session has been created.

Question - 62 : - What happens when a page is statically included in another JSP page?

Answer - 62 : - An include directive tells the JSP engine to include the contents of another file (HTML, JSP, etc.) in the current page. This process of including a file is also called as static include.

Question - 63 : - What is the page directive is used to prevent a JSP page from automatically creating a session?

Answer - 63 : - <%@ page session="false">

Question - 64 : - How do I include static files within a JSP page?

Answer - 64 : - Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.

Question - 65 : - What is the difference between RequestDispatcher and sendRedirect?

Answer - 65 : - RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.

Question - 66 : - How do I mix JSP and SSI #include? What is the difference between include directive & jsp:include action?

Answer - 66 : - Difference between include directive and 1. provides the benefits of automatic recompliation,smaller class size ,since the code corresponding to the included page is not present in the servlet for every included jsp page and option of specifying the additional request parameter. 2.The also supports the use of request time attributes values for dynamically specifying included page which directive does not. 3.the include directive can only incorporate contents from a static document. 4. can be used to include dynamically generated output e.g.. from servlets. 5.include directive offers the option of sharing local variables, better run time efficiency. 6.Because the include directive is processed during translation and compilation, it does not impose any restrictions on output buffering.

Question - 67 : - Can we use the constructor,  instead of init(), to initialize servlet?

Answer - 67 : - Yes , of course you can use the constructor instead of init(). There’s nothing to stop you. But you shouldn’t. The original reason for init() was that ancient versions of Java couldn’t dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won’t have access to a ServletConfig or ServletContext.

Question - 68 : - What is JSP page?

Answer - 68 : - A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format such as HTML, SVG, WML, and XML, and JSP elements, which construct dynamic content.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners