Find Interview Questions for Top Companies
Ques:- What is the advantage of using getProperty action, as compared to the accessor method?
Right Answer:
The advantage of using the `<jsp:getProperty>` action is that it allows you to directly access and display a property of a JavaBean in JSP without needing to write Java code or call the accessor method explicitly. This simplifies the code and enhances readability.
Ques:- can i extend jsp page like other java classes ?
Asked In :- fujitsu,
Right Answer:
No, you cannot extend a JSP page like other Java classes. JSP pages are compiled into servlets, and they do not support inheritance in the same way that Java classes do.
Comments
Admin May 17, 2020

we can't extend jsp page

Admin May 17, 2020

Yes, we can extend a jsp from another.
this is some tricky and discouraged by sun specification.
because you may lose any optimizations that your JSP
container provides.

Ques:- how to connect the back end with Directive tag in jsp …
Asked In :- multicoreware, inc,
Comments
Admin May 17, 2020

A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets.
<%@ page language=”java” contentType=”text/html”
import=”java.sql.*,java.sql.Statement %>
<%
//load the Oracle JDBC driver or any other driver for a specific
vendor
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);
//open a connection to the “scott” database or other database which you have created. You should provide the username and password as part of this connection string. Here the username and password are scott and tiger.
Connection con=
DriverManager.getConnection(”jdbc:odbc:scott”,”scott”,”tiger”);
//create a statement object for sending SQL queries
Statement stmt = con.createStatement();
//place query results in a ResultSet object
//To get all projects of a particular project leader.
ResultSet res = stmt.executeQuery(” select * from employee”);
String ename=null;
%>
Further then you can use the resultset object “res” to read data in the following way.
<%
while(res.next())
{
ename=res.getString(”ename”);
%>

Ques:- Plz any body tell me why use jsp over servlet.what is the benefit of jsp over servlet?
Right Answer:
JSP is preferred over servlets because it allows for easier and faster development of dynamic web pages by separating the presentation layer from the business logic. JSP uses HTML-like syntax, making it more intuitive for designing user interfaces, while servlets require more Java code for the same tasks. Additionally, JSP supports tag libraries and custom tags, enhancing reusability and maintainability.
Comments
Admin May 17, 2020

From a coding point of view if we want to send some text as
response back to client browser
The Servlet way is:
response.write("<p>hello</P>");
The JSP is:
<p>hello</P>
------------------------------------------------------------
JavaServer Pages (JSP) is a Java technology that allows
software developers to create dynamically-generated web
sites, with HTML, XML, or other document types, in response
to a Web client request.
So Sending information to clients without manipulating it
JSP is best i.e sending same output to every user of your
web applcation. JSP is used to Present the [ HTML/XML
output ] to user also called Presenation Logic.
Example : Users A, B, C enter wrong password while logging
to an application they will be shown same Message as JSP
Page Output: "Invalid Username/Password entered by the
user".
Since Here Output for each user is same so JSP is used.
------------------------------------------------------------
But for doing serious computations on data before (ie
Business logic) sending the respone back Servlets are best.
Servlets are used when you want to do some processing on
data submitted by the user, For example : Computing Income
Tax for a particular user based on criteria selected by the
user.
Income Tax computation result for a User A having Income 2
Lakhs per year will be different from User B having Income
5 Lakhs. So here we will use Servlet to compute the Income
Tax.
This allows for isolation of Business logic[Computing
Income Tax] from Presentation logic[Showing same message -
"Invalid Username/Password entered by the user"].
------------------------------------------------------------
Performance JSP vs Servlet :
JSP`s are internally compiled into Servlet code by JSP
Compiler. So If a request is mde to JSP page from Browser
for the first time JSP page will take more time to load
into the browser as it will be first compiled into a
servlet and then that [JSP converted Servlet] will be
executed.
Next time you request the same JSP page it will load faster
as it is already converted to servlet so servlet code will
execute then.
------------------------------------------------------------
Application Server Re-Start :
Servlets :
If Some Change is made in Servlet code then Application
Server on which servlet runs require to be re-started so as
to reflect the new change to the users of the application.
JSP : There is no need to re-start the Application Server
if JSP code change is made.
------------------------------------------------------------

Admin May 17, 2020

if any changes in jsp file need not compile every time. just
save the jsp page and refresh the browser page.
but in servlet we need compile and deploy and run again.

Ques:- What’s the difference between an import and include directive, and also the difference between include directive and include action?
Comments
Admin May 17, 2020

import directive is used to import any java classes into the jsp. eg : import java.lang.String, whereas include directive is used to include a content of another jsp.
'include' directive is used to include content from a jsp which is static for ever once the jspServlet created for it. The include jsp will not compipled each and every time it gets loaded Header and footer jsps can be included in this method.
If any jsp is included thru include action, the content of the jsp will be compiled and the respective output will be generated and rendered to the including jsp each and every time the including jsp is getting loaded.

Ques:- what is difference between the contart and implementation?
Right Answer:
In JSP, a contract refers to the defined interface or specification that outlines what methods and functionalities should be available, while implementation is the actual code that fulfills that contract, providing the specific behavior and logic.
Ques:- when we will use the SendRedirect method instead of forward.
Asked In :- 63 moons technologies,
Comments
Admin May 17, 2020

When there is no need to record/maintain the previous data
of the user.
Like in google we are searching some infom
and after clicking on the searched item, it will forward to
some other server or link, where there is no required to
maintain any previous information of user.
that depends you need to think about the Scenario and use.

Ques:- what will happen if we disable cookies in the web page?
Asked In :-
Right Answer:
If cookies are disabled on a web page, the website will not be able to store or retrieve any data related to the user's session, preferences, or login information. This may lead to a loss of functionality, such as not being able to stay logged in, remember items in a shopping cart, or maintain user-specific settings.
Comments
Admin May 17, 2020

I we disable cookies then it will bedifficult for the web
container to manage the session with the help of cokkie.So
we need to use the encodeURL() method for appending the
jsessionid with the URL.

Admin May 17, 2020

Cookies is used for identify to request.
if we disable the coookies then we cannot identify the
request

Ques:- When i am useing useBean tag of JSP in weblogic server It show compiletion error..Like bad class file: C:beauser_projectsdomainsMaheshapplicationsUseBeanWEB-INFclassesuserUserData.class class file has wrong version 49.0, should be 48.0 Please remove or make sure it appears in the correct subdirectory of the classpath. user.UserData user1 = null; //[ /SaveName.jsp; Line: 4]
Ques:- How can i connect from jsp to servlet page
Comments
Admin May 17, 2020

Using <jsp:include> or <jsp:forward> we can dispath the
request form a jsp to servlet.
<jsp:include file="Actionservlet"/>

Admin May 17, 2020

By calling formaction
<form action="Name Declared in web.xml" method="post">

Ques:- How To maintain session ..?
Comments
Admin May 17, 2020

you can maintain session in 4 ways--
1. hidden form field eg.
<input type=hidden name=button1 value = butvalue>
2. Using cookie
3 . URL Rewriting
4 . Session Attribute - setAttrubute(key, value) and
getAttribute(key)

Admin May 17, 2020

using cookies,url redirecting,

Ques:- how the jsp file is compiled?
Comments
Admin May 17, 2020

when container sees the request for .jsp file it loads
the .jsp file &converts into .java then compiles
into .class file and it is servlet all the way(continer
calss its no-arg constuctor,calss jspInit(),_jspservice()&
finally jsp destory)

Ques:- How do I set password expire time period?
Comments
Admin May 17, 2020

I created another column in my user table expiration date. When user signs up and created the password. added 90 days to current sysdate and inserted in expiration date.
When the user tried to login in the system will check expiration date is greater than the current date.
When the user update his password will change expiration date adding 90 days to current system date.

Ques:- hi i m tannu and i m developing one web site as my project and i have created one chatting application using applet and socket it run perfactly using netbeans5.5 and appletviewer but when i run on browser it doent run i put it class file in jar file then call by jsp when it load in browser it stop on applet started plz help me soon
Asked In :- silverlake axis,
Comments
Admin May 17, 2020

Hi ur application was hacked by the some programmers..
u better develop one more application

Admin May 17, 2020

Hey Tannu,
Can't u find some better project rather than a 500 year old
chatting application. Some 20lakh-50 lakh Chatting
applications are there on the net.
Start doing something interesting rather than some stupid
old chatting application.

Ques:- why JSP is bigger choice for software development as compare to ASP.
Comments
Admin May 17, 2020

Jsp mens Java Server Pages it requires any java enabled web
server for running and as we know that java is a sun
product and Sun always comes with best product and JSp
follows all java properties and it is a Object oriented
base language.
ASP runs on microsoft related server.

Admin May 17, 2020

Jsp's are better choice as jsp can be easily turned to
Servlets where the servlet container understands.
As most of the projects run with java/j2ee, it is very easy
to understand for the servlet engine, rather Asp being in
third party language.

Ques:- What are the implicit objects?
Comments
Admin May 17, 2020

JSP is oop base language but you can not create any class
or any object in JSP page that's why container provides
some in build objects--as given above answer.

Admin May 17, 2020

Implicit objects are objects that are created by the web
container and contain information related to a particular
request, page, or application. They are:
--request
--response
--pageContext
--session
--application
--out
--config
--page
--exception

Ques:- What is the difference between JSP and Servlet?
Asked In :- chetu, GKMIT,
Comments
Admin May 17, 2020

Servlets are pure java programs.here we can't use HTML.
But in JSP we use HTML,so we can use and modify the data
very easily.
Servlets are faster than JSP.bcoz while running JSP
programs it will be converted into Servlets and then
executed,so it takes more time.

Admin May 17, 2020

Both servlet and jsp are web components. But servlet is
best suited for request processing, handling the business
logic while jsp is suitable for content generating .Its
easy to include html tag in jsp rather than servlet.Also
jsp is compiled to servlet when first loaded to
webserver.So in many framework servlet act as a controller
while jsp as a view.Also implicit object and action
elements available in jsp but not in servlet.

Ques:- Can we override serivice()method in jsp?
Comments
Admin May 17, 2020

NO
because all the JSP code will get translated within the
service methode.

Ques:- Can init method be overridden?
Comments
Admin May 17, 2020

YES. jspInit() and jspDestroy() method van be overrideen,
but _jspService() can not be.



The Java skill section on takluu.com is designed for freshers, intermediate developers, and experienced professionals aiming to crack Java-based technical interviews with confidence. Java remains one of the most in-demand programming languages, and mastering it opens the door to countless opportunities in backend development, enterprise solutions, Android apps, and cloud-based platforms.

Our Java category covers everything from Core Java concepts like OOPs (Object-Oriented Programming), Data Types, Loops, and Exception Handling to Advanced Java topics including Collections Framework, Multithreading, JDBC, Servlets, JSP, Lambda Expressions, and Streams. We provide practical coding examples, real interview questions (with answers), and key concept explanations that interviewers commonly test.

Whether you’re applying for a role like Java Developer, Backend Engineer, or Full Stack Developer, this section ensures you understand the logic, syntax, and problem-solving approaches that matter in real-world interviews. You’ll also find scenario-based questions and discussions around design patterns, JVM internals, garbage collection, and performance tuning — areas often explored in senior-level interviews.

Each topic is structured to help you revise quickly and efficiently, with quizzes and mock interviews to assess your understanding. Our content is curated by experts who have worked with Java across different domains and keep the material aligned with current industry trends.

At Takluu, we believe in not just learning Java — but preparing to think in Java. Get ready to face interviews with clarity, confidence, and a deep understanding of what makes Java so powerful and reliable.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users