- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
JSP Interview Questions & Answers - Learning Mode

JSP Interview Questions & Answers - Learning Mode

JavaServer Pages (JSP) is a Java technology that allows software developers to dynamically generate HTML, XML or other types of documents in response to a Web client request. The technology allows Java code and certain pre-defined actions to be embedded in any web application.

Try JSP Interview Questions & Answers - Exam Mode

1 2 3 4 5 6 7 8 9 10 11 Next

Sort By : Latest First | Oldest First | By Rating

JSP Interview Questions & Answers - Learning Mode
Try JSP Interview Questions & Answers - Exam Mode
Question: Can a JSP page instantiate a serialized bean?

Answer: No problem! The useBean action specifies the beanName attribute, which can be used for indicating a serialized bean.

For example:

<jsp:useBean id="shop" type="shopping.CD" beanName="CD" />
<jsp:getProperty name="shop" property="album" />

A couple of important points to note. Although you would have to name your serialized file "filename.ser", you only indicate "filename" as the value for the beanName attribute. Also, you will have to place your serialized file Source:
Question: Can one JSP or Servlet extend another Servlet or JSP

Answer: Hey a servlet cant extend a class or servlet a it already extends HTTpServlet.....But if you can make the servlet work withought extending HTTpSERvlet then u can do that...but then as far as i know it wontb a servlet and will be somple classjsp can exend a class Source:
Question: What is the difference between include directive & jsp:include action?

Answer: Difference between include directive and <jsp:include>

1.<jsp:include> provides the benifits 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 <jsp:include> also supports the use of request time attributes valus for dynamically specifying included page which directive does not.
3.the include direc Source:
Question: How to overwrite the init and destroy method in a JSP page.

Answer: We can overwrite the init method in a jsp page by using declaration tag in our JSP page.
Question: What is difference between scriptlet and expression

Answer: Anything that is put in the Jsp Expression tag get evaluated to a string, which, technically becomes an argument to the println() statement in the generated servlet.( JSP eventually is converted to a servlet ) otherwise it serves no purpose on its own.

Expression has the following syntax


Question: Can you make use of a ServletOutputStream object from within a JSP page?

Answer: No. You are supposed to make use of only a JSPWriter object (given to you in the form of the implicit object out) for replying to clients.

A JSPWriter can be viewed as a buffered version of the stream object returned by response.getWriter(), although from an implementational perspective, it is not.

A page author can always disable the default buffering for any page using a page directive as:

<%@ page buffer="none" %> Source:
Question: How can I restrict the user from Clicking of Back button in any browser?

Answer: One of the way to restrict the user to Go back by disabling the back button can be done using the Following Script.

Please use the script in the <Head> tag of the every page you design(it works in Internet explorer . C# using




Question: What are advantages of JSP?

Answer: We can separate the Presentation Logic from Business Logic in JSP'S where as Servlets we can't make it.

Submitted by Sobhan (


The two main uses of jsps are:

1) Using jsp's we can can seperate the presentation logic from business logic very easily(we can also do the same using the servlets but difficult)

2) Even a web author can easily develop the code ,in the sence a person who doesnt know anything abou Source:
Question: How to delete cookies in JSP?

Answer: Whenever you want to delete cookies, just set the Maxtime value to 0..

example given below.

Cookie cookie = new Cookie ("myCookie", "theCookieValue");

// Expire in five minutes (5 * 60)
cookie.setMaxTime( 300 );

some... more code here.. or any other page..

// Expire after the browser is closed
// cookie.setMaxTime( -1 );

// Expire right now
// cookie.setMaxTime( 0 );

Question: What is difference between JSP 1.0 model and JSP 2.0 model

Answer: The main difference between the jsp 1.0 and jap 2.0 is that jsp 2.0 has feature in that by which we can generate more syntax errors due to TLD. Source:
Question: What is the difference between declaring the variables in the scriptlet tags and in the declaration tags?

Answer: Declaring the variables in the scriptlet is gone into the service method when jsp converted into servlet but in declaration tags goes into the class label variable Source:
Question: I have to view(in a JSP Page)the rows in a
database which contains some thousands of
rows.But in a page i have to view only 20
rows and by pressing the hyperlinks in the
page(for an example :page1, page2)i have to
view the rest of the records.
Each page should contain 20 records only.
Kindly give me an idea or some sample coddings to design the above JSP page.

Answer: Firstly send a request to server and calculate how many row are exists for executed query and store it into count.
if its more than 20 than dived (pages = count/20)
execute query like select top twenty from database, store 20th id in session variable. and activate page links and append 1...n with page wher n = no. of pages and pages = count/20.
When user click on page2 at that check appended digit to page link if it is greater than previous one than
time execute query select top 2 Source:
Question: How can we move from one JSP page to another(mean using what tecnique?)

Answer: A Jsp can either "redirect "or "dispatch " to another JSP.
// use this if you just want to invoke another
response.sendRedirect("Jsp URL");

// use this if you want to pass info from one
// jsp to another jsp

RequestDispatcher dispatch = request.getRequestDispatcher("The Jsp File Name");

dispatch.forward(request, response);
Question: How to pop up a jsp page?refreshing every two seconds.

Answer: You need to take help of HTML Auto refresh facility to achive this task. Please search google to know more about auto refresh html tag. You can also do view source of few stock or cricket site which have this autorefresh factility. Source:
Question: How do you pass control from one JSP page to another?

Answer: Use the following ways to pass control of a request from one servlet to another or one jsp to another.

? The RequestDispatcher object ?s forward method to pass the control.

? The response.sendRedirect method

Submitted By: Rekha ( rekha.s @ enrichsolutions . com )
Question: What are the implicit objects in JSP & differences between them?

Answer: There are 9 Implicit Objects defined in JSP are :
application, config, exception, out, page, pageContext, request, response and session.

The main difference between these Objects lies in their scope and the data they handles.

Submitted by Sagar GV (

JSP Implicit Objects :-

S.No Implici Object Class or Interface Source:
Question: How can we move from one JSP page to another(mean using what tecnique?)

Answer: <jsp:forward page="/pagename" /

Question: Can we override the jspInit(), _jspService() and jspDestroy() methods?

Answer: We can override jspinit() and jspDestroy() methods but not _jspService(). Source:
Question: Can a single JSP page be considered as a J2EE application?

Answer: Yes, if its packed as war or if it's directory structure confirms j2ee specifications with a dd Source:
Question: How the jsp changes will be effected in servlet file after converting?

Answer: Here jsp engine cheack whether jsp page is older than its servlet page or not and on the basis of this it it's decide whether changes are needed or not. Source:

1 2 3 4 5 6 7 8 9 10 11 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.6875 Seconds