50+ JSP Interview Questions

50+ JSP Interview Questions

JSP Interview Questions

1) What is JSP? 

Java Server Pages innovation (JSP) is a server-side programming language used to make a dynamic website page as HyperText Markup Language (HTML). It is an expansion to the servlet innovation.

A JSP page is inside changed over into the servlet. JSP approaches the whole group of the Java API including JDBC API to get to big business database. Thus, Java language punctuation has been utilized in the java server pages (JSP). The JSP pages are more open to keep up than Servlet on the grounds that we can isolate structuring and advancement. It gives some extra highlights, for example, Expression Language, Custom Tags, and so forth.

2) What are the life-cycle techniques for a JSP? 

Method Description

open void jspInit() It is summoned just once, same as init strategy for the servlet.

open void _jspService(ServletRequest request,ServletResponse)throws ServletException,IOException It is conjured at each solicitation, same as administration() technique for the servlet.

open void jspDestroy() It is summoned just once, same as annihilate() technique for the servlet.

3) List out certain favorable circumstances of utilizing JSP. 

Better execution.

The aggregation of JSP is done before it is prepared by the server which destroys the requirement for stacking of translator and code content each time.

JSP approaches every single ground-breaking venture.

Simple to keep up: JSP can be effectively overseen in light of the fact that we can without much of a stretch separate our business rationale with introduction rationale. In Servlet innovation, we blend our business rationale with the introduction rationale.

JSP can likewise be utilized in mix with servlets.

4) Give the punctuation for JSP remarks. 

The punctuation for JSP remarks is:

<%- - Comment - %>

5) What is the contrast between conceal remark and yield remark? 

The JSP remark is called conceal remark while HTML remark is called yield remark. In the event that a client sees the wellspring of the page, the JSP remark won't be appeared while HTML remark will be shown.

6) What are the JSP certain items? 

JSP gives nine certain items as a matter of course. They are as per the following:

Object Type

1) out JspWriter

2) request HttpServletRequest

3) response HttpServletResponse

4) config ServletConfig

5) session HttpSession

6) application ServletContext

7) pageContext PageContext

8) page Object

9) exception Throwable

7) What is the contrast between incorporate mandate and incorporate activity? 

incorporate directive include activity

1) The incorporate mandate incorporates the substance at page interpretation time. 1) The incorporate activity incorporates the substance at solicitation time.

2) The incorporate mandate incorporates the first substance of the page, so page estimate increments at runtime 2) The incorporate activity does exclude the first substance rather summons the incorporate() technique for Vendor gave class.

3) It's better for static pages. 3) 3) It's better for dynamic pages.

8) Is JSP innovation extensible? 

Indeed. JSP innovation is extensible through the advancement of custom activities, or labels, which are embodied in label libraries.

9) How would i be able to actualize a string safe JSP page? What are the preferences and Disadvantages of utilizing it? 

You can make your JSPs string safe by having them execute the SingleThreadModel interface. This is finished by including the mandate <%@ page isThreadSafe="false" %> inside your JSP page.

10) How would i be able to keep the yield of my JSP or Servlet pages from being reserved by the program? 

(Or on the other hand) How to incapacitate storing on the back catch of the program?




response.setHeader ("Expires", "0");/anticipates reserving at the intermediary server


11) How would we be able to deal with the special cases in JSP? 

There are two different ways to perform special case taking care of, one is by the errorPage component of page order, and second is by the mistake page component of the web.xml record. 

12) What are the two different ways to incorporate the aftereffect of another page. ? 

There are two different ways to incorporate the aftereffect of another page:

By incorporate mandate

By incorporate activity

13) How would we be able to advance the solicitation from JSP page to the servlet? 

Indeed obviously! With the assistance of "forward activity" tag, yet we have to give the URL-example of the servlet.

forward activity tag

14) Can we utilize the special case certain item in any JSP page? 

No. The special case certain item must be utilized in the mistake page which characterizes it with the isErrorPage trait of page mandate.

15) How is JSP utilized in the MVC demonstrate? 

JSP is generally utilized for introduction in the MVC design (Model View Controller ), i.e., it assumes the job of the view. The controller manages calling the model and the business classes which thus get the information, and this information is then displayed to the JSP for rendering on to the customer.

forward activity tag

16) What are setting instatement parameters? 

Setting instatement parameters are indicated by the in the web.xml document, and these are introduction parameter for the entire application and not explicit to any servlet or JSP. 

17) What are the diverse degree esteems for the tag? 

There are 4 esteems:





18) What do JSP literals comprise of? 


Whole number

Drifting point



19) What is the motivation behind

The jsp:useBean activity looks for the presence of the article with determined name. If not discovered, it makes one.

20) What is the reason for

This activity sets the properties of a bean.

21) What is the reason for

This activity recovers the properties of a bean.

22) List out the different degree estimations of JSP activity. 

The conceivable extension esteems are:





23) What is the utilization of 'out' verifiable article? 

The item is utilized to give a reaction to substance.

24) Give the utilization of session object. 

The article is utilized between the customer demands for the following of customer sessions.

25) Give the utilization of special case object. 

The article is utilized for the age of a reaction to the blunders tossed.

26) What is the distinction among ServletContext and PageContext?- 

ServletContext gives the data about the holder though PageContext gives the data about the Request.

27) What is the distinction in utilizing request.getRequestDispatcher() and context.getRequestDispatcher()? 

request.getRequestDispatcher(path) is utilized to make it we have to give the overall way of the asset though context.getRequestDispatcher(path)to make it we have to give the outright way of the asset.

28) What is EL in JSP? 

The Expression Language(EL) is utilized in JSP to streamline the openness of articles. It gives numerous articles that can be utilized legitimately like param, requestScope, sessionScope, applicationScope, demand, session, and so forth.

29) What are the essential contrasts between the JSP custom labels and java beans? 

Custom labels can control JSP content while beans can't.

Complex tasks can be decreased to a fundamentally more straightforward structure with custom labels than with beans.

Custom labels require a lot more work to set up than do beans.

Custom labels are accessible just in JSP 1.1 and later, however beans can be utilized in all JSP 1.x forms.

30) Can an interface be actualized in the JSP record? 


31) What is JSTL? 

JSP Standard Tag Library is a library of predefined labels that facilitate the advancement of JSP.

More subtleties.

32) what number labels are given in JSTL? 

There is 5 sort of JSTL labels.

center labels

sql labels

xml labels

internationalization labels

capacities labels

33) Which mandate is utilized in JSP custom tag? 

The JSP taglib mandate.

34) What are the three labels utilized in JSP bean advancement? 




More subtleties.

35) How to incapacitate session in JSP? 

<%@ page session="false" %>

36) List the different activity labels utilized in JSP. 

Following are the rundown of different activity labels utilized in JSP:

jsp:forward: This activity label advances the solicitation and reaction to another asset.

jsp:include: This activity tag is utilized to incorporate another asset.

jsp:useBean: This activity tag is utilized to make and finds bean object.

jsp:setProperty: This activity tag is utilized to set the estimation of the property of the bean.

jsp:getProperty: This activity tag is utilized to print the estimation of the property of the bean.

jsp:plugin: This activity tag is utilized to implant another segment, for example, the applet.

jsp:param: This activity tag is utilized to set the parameter esteem. It is utilized in forward and incorporates generally.

jsp:fallback: This activity tag can be utilized to print the message if the module is working.

37) Explain the means for making custom labels in JSP? 

For making any custom tag, we have to pursue the accompanying advances:

Make the Tag handler class

To produce the Tag Handler, we are acquiring the TagSupport class and abrogating its strategy doStartTag().To compose information for the JSP, we have to utilize the JspWriter class.

The PageContext class gives getOut() strategy that profits the example of JspWriter class. TagSupport class gives an example of pageContext as a matter of course.

Make the TLD document

Label Library Descriptor (TLD) document contains data of tag and Tag Hander classes. It must hold inside the WEB-INF registry.

Make the JSP document

We should utilize the tag in our JSP document. Here, we are indicating the way of tld document legitimately. In any case, it is prescribed to utilize the URI name rather than full a way of tld record. We will find out about URI later. It utilizes taglib mandate to utilize the labels characterized in the tld document.

38) How can the applets be shown in the JSP? Clarify with a model. 

The jsp:plugin activity tag is utilized to implant an applet in the JSP record. The jsp:plugin activity tag downloads module at customer side to execute an applet or bean.

Case of showing applet in JSP


Mouse Drag

Mouse Drag Example

type="applet" code="MouseDrag.class" name="clock" codebase="."/>

39) What is Expression language in JSP? 

The Expression Language (EL) improves the availability of information put away in the Java Bean segment, and different items like solicitation, session, application.

There are numerous verifiable items, administrators and save words in EL.

It is the recently included component in JSP innovation adaptation 2.0.

40) Explain different understood articles in articulation language. 

Certain Objects Usage

pageScope it maps the given property name with the esteem set in the page scope

requestScope it maps the given characteristic name with the esteem set in the solicitation scope

sessionScope it maps the given property name with the esteem set in the session scope

applicationScope it maps the given property name with the esteem set in the application scope

param it maps the solicitation parameter to the single esteem

paramValues it maps the solicitation parameter to a variety of qualities

header it maps the solicitation header name to the single esteem

headerValues it maps the solicitation header name to a variety of qualities

cookie it maps the given treat name to the treat esteem

initParam it maps the introduction parameter

pageContext it gives access to numerous items demand, session, and so on.