Jsp Interview questions (20 interview questions)
There is a list of 20 jsp interview questions. If you know any jsp interview question that has not been included here, post your question in the Ask Question section.
1)What is JSP?
Java Server Pages technology (JSP) is used to create dynamic web page.It is an extension to the servlet.A JSP is internally converted into servlet.more details...
2)What are the life-cycle methods for a jsp?
3)What is difference between hide comment and output comment?
The jsp comment is called hide comment whereas html comment is called output comment.If user views the source of the page, the jsp comment will not be shown whereas html comment will be shown.
4)What are the JSP implicit objects ?
JSP provides 9 implicit objects bydefault.They are as follows:
5)What is difference between include directive and include action?
6)Is JSP technology extensible?
Yes. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.
7)How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it?
You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe="false" %> within your JSP page.
8)How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
(OR) How to disable caching on back button of the browser?
<% response.setHeader("Cache-Control","no-store"); response.setHeader("Pragma","no-cache"); response.setHeader ("Expires", "0"); //prevents caching at the proxy server %>
9)How can we handle the exceptions in JSP ?
There are two ways to perform exception handling, one is by the errorPage element of page directive, and second is by the error-page element of web.xml file.more details...
10)What are the two ways to include the result of another page. ?
There are two ways to include the result of another page:
11)How can we forward the request from jsp page to the servlet ?
Yes ofcourse! With the help of forward action tag, but we need to give the url-pattern of the servlet.forward action tag
12)Can we use the exception implicit object in any jsp page ?
No. The exception implicit object can only be used in the error page which defines it with the isErrorPage attribute of page directive.more details...
13)How is JSP used in the MVC model?
JSP is usually used for presentation in the MVC pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals with calling the model and the business classes which in turn get the data, this data is then presented to the JSP for rendering on to the client.
14)What are context initialization parameters?
Context initialization parameters are specified by the <context-param> in the web.xml file, these are initialization parameter for the whole application and not specific to any servlet or JSP.more details...
15)What are the different scope values for the <jsp:useBean>?
16)What is the difference between ServletContext and PageContext?-
ServletContext gives the information about the container whereas PageContext gives the information about the Request.
17)What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?
request.getRequestDispatcher(path) is used in order to create it we need to give the relative path of the resource whereas context.getRequestDispatcher(path) in order to create it we need to give the absolute path of the resource.
18)What is EL in JSP?
The Expression Language(EL) is used in JSP to simplify the accessibility of objects. It provides many objects that can be used directly like param, requestScope, sessionScope, applicationScope, request, session etc.
19)What is basic differences between the JSP custom tags and java beans?
20) Can an interface be implemented in the jsp file ?