Q.1. What is JSP?
Answer: JSP is an abbreviation for Java Servlet Page. It is a Server-Side Programming Language used to create dynamic web-pages in the form of HTML. The JSP page is implicitly converted into a servlet and it enables some additional features such as Expression Language, Custom Tags, and many more.
Q.2. How can you include the results of another page?
Answer: The results of another page can be included by using the following methods:
(i) Include Directive
(ii) Include Action
Q.3. How can I use JSP in the MVC model?
Answer: JSP is used in MVC in the presentation tasks. It is used as a view. The controller calls the model and the business classes that get the data. This data is rendered to the JSP for rendering it to the Client.
Q.4. Mention the scope values for <jsp.useBean> tag.
Answer: There are mainly four scope values available for <jsp.useBean> tag.
(i) page
(ii) request
(iii) application
(iv) session
Q.5. What are the Literals used in JSP?
Answer: The Literals used in JSP are as follows:
(i) Null
(ii) Boolean
(iii) String
(iv) Integer
(v) Float
Q.6. What is the major difference between ServletContext and PageContext?
Answer: The major difference between ServletContect and PageContext is, the ServletContext is designed to provide information about the Container and on the other hand, the PageContext is designed to provide information about the Request.
Q.7. Why are the request.getRequestDispatcher() and context.getRequestDispatcher() used?
Answer: The RequestDispatcher() and the context.getRequestDispatcher() are used for the following purposes.
(i) request.getRequestDispatcher() is used to create request. We need to give the relative path of the resource.
(ii) context.getRequestDispatcher() is used to create context. We need to give the absolute path of the resource.
Q.8. Mention the three important tags used in the development of JSP Bean.
Answer: The Three tags used in the JSP Bean development are as follows:
(i) jsp:useBean
(ii) jsp:setProperty
(iii) jsp:getProperty
Q.9. Mention the Implicit Objects in a JSP.
Answer: The Web Container creates certain objects that include the information related to a particular Request, Application or a Page. These Objects are called as Implicit Objects. The Implicit Objects in the JSP are as follows:
(i) Request
(ii) Response
(iii) Application
(iv) Exception
(v) Config
(vi) Page
(vii) Session
(viii) PageContext
(ix) Out
Q.10. Can you stop Multiple Submits to a Web Page that are initiated by clicking to refresh button?
Answer: Yes, This issue can be solved by using a Post/Redirect/Get or a PRG pattern.
(i) A form filed by the user gets submitted to the server using POST/GET method.
(ii) The state in the database and business model are updated.
(iii) A redirect response is used to reply by the servlet for a view page.
(iv) A view is loaded by the browser using the GET command and no user data is sent.
(v) This is safe from multiple submits as it is a separate JSP page.