what is the difference between Servlet and JSP?Advantage of
JSP over Servelt?Any concept present in JSP which we cant
implement in Servlet?

Answers were Sorted based on User's Feedback



what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / sree

Servlet is a Java Mechanism which is a part of J2SE(J2SE was also said by some pgmers as Java 2 Servlet edition) and further implemented into J2EE and now on JEE. The difference between servlets and jsp is that in JSP each page is considered as a single dynamic page from which the reference to other pages are very easy ... for example.. in servlet to forward a page from html we use:<form method=post action="http://localhost:8080/ctxt/java_class"> but in jsp we just give <form method=post action="filename.jsp"> ! But how does this work.. The server just takes the filename.jsp and converts that into a filename.class and inserts http://localhost :8080/ctxt root in front of it(A virtual assumption for understandability) and communicates...so the programming complexity is generaaly reduced.. and ther are loo of differences given by others and hence i just liked to share this information with you people.
Thankyou.

Is This Answer Correct ?    6 Yes 5 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / nv

The difference b/w servlet and jsp is :
1. In servlet html is embedded with java code but in jsp
java code is embedded with html.
2. jsp is a long process because in jsp code is convert to
servlet at the time of deployment.
3. servlet are fast process than jsp.
4. no need to deploy jsp ,in servlet we need web.xml but no
need to use in jsp.

Is This Answer Correct ?    1 Yes 0 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / vinit srivastava

JSp is the extension of Servlet which simplyfiy development
of web application by facilitating embedding of dynamic
content generation logic into html pages.

Application developers used to write presentation logic in
servlet which result in a maintenence problem.

Development of servlet is a triesone process.

Is This Answer Correct ?    2 Yes 1 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / sandeep

All the java code is embedded in jsp.......
but it is defferenciated in servlets...
Advantage of servlet over jsp is jsp is more fater than servlet

Is This Answer Correct ?    1 Yes 0 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / prashant bari

&#61558; Difference between JSP & Servlet:-
Before moving to the actual discussion let us have glimpse
on following points.
1. HTML, JSP & Servlet-
a. By using HTML only static part of the webpage can
be designed.
b. So there was a need of some other coding option to
create dynamic content for web page. Both servlet & JSP can
be used for this purpose. The way they can be used to
create dynamic content of the web page constitutes one of
the difference between them.
i. Sevlet contain HTML code in java code.
ii. JSP Contain java code in HTTP code.
This arose a question ”When to use which?”
2. When to use which?
There are two more things we need to understand those are
Presentation logic & Business logic.
Presentation logic deals with how the information is
presented.
Business logic usually written in java code contains coding
for business decisions like “if customer will purchase
goods above rupees 300 allow 10 % discount.”
Ideally business logic & presentation logic should be
separate. Why?
a. Modularity & ease of design.
b. Abstraction (why to explorer business logic to
coder)?
3. How JSP & Servlet implement business logic &
Presentation logic?
a. JSP-
i. Presentation logic is defined in JSP file.
ii. Business logic defined in java Beans.
b. Servlet-
i. Static presentation defined in HTML
ii. Dynamic presentation and business logic in servelet
4. Now the answer…
Consider a scenario of retail industry where business i.e
business logic decisions frequently change. If servlet is
used for such web application. For each change in business
logic we will need to recompile those servlets.
But if we use JSP for this the changes in business logic
can be done in Beans without touching presentation logic.
5. Then why to use Servlet?
Answer is
&#61692; When performance is important- as we know JSP is
again converted to servlet it will be two step process.
6. Final confusion- as just stated if JSP is also
converted to servlet internally then if change in business
logic needs to recompile servlet again will it not be the
case in JSP?
Answer is no!!! because presentation logic in JSP is
separate from Buisness logic in bean. The code on JSP only
know how to invoke service from bean. So long as the method
name, parameters & return type remains the same the
business logic developer can easily change rest of the
method.
e.g method in business logic
class BeanDemo
{
int area(int a)
{
Int area;
Area=a*a;
Return()
}
}
The method will appear as follows in presentation logic.
BeanDemo bd=new BeanDemo();
Int a=bd.area();

Now if tomorrow if business logic developer change the
method definition to
class BeanDemo
{
int area(int a)
{
Int area;
Area=a*a;
Return()
}
}
Will it affect the presentation logic code? Surely not. It
wont even need to be recompile what will be needed is re
compiling only business logic part i.e BeanDemo class not
the JSP calling the method..

Bottom line-
1. Use JSP for presentation Logic and ideally include
no business logic.
2. Use Beans for Business Logic and ideally include no
presentation logic.

Is This Answer Correct ?    2 Yes 1 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / tarun pundreek sharma

JSP is a server side technology given by sun microsystem after servlet technology. we have some drawback in servlet to overcome those drawback and also to attract programmers working on other domain the sun micro system introduce JSP.

Advantages of JSP:-

1: we need to re-compile our servlet for every single change in the source code of servlet , where as in the case of JSP re-compilation is not required since JSP are automatically handle by the web container for any update in their code.

2: servlet can not be access directly & have to be first mapped in the web.xml file.where as the jsp page access directly as a simple HTML page.

3: both servlet & jsp are server side components used to generate dynamic Html pages however JSP is preffered over servlet as it is developed by using a simple HTML template
& automatically handled by the JSP container.

4: JSP is a tag based approach it makes it easy to understand.

Is This Answer Correct ?    1 Yes 0 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / sushrut

1)servlet is like html inside java code and jsp is like java code inside html
2)jsp have predefined variables(request,response,session),
whether servlet haven't.

Is This Answer Correct ?    1 Yes 0 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / twinkle

Servlet is a single instance multiple thread web
application in which HTML code can be included in java code.
JSP is also a web application in which java code can be
included in HTML code.
For compilation of servlet we need to close TOMCAT server
each n every time but for JSP's no need
EX:If u made any changes in program u need to close TOMCAT
server and then again start the server.But in JSP u just
need to click refresh tats it.
In servlets u need to write the whole class name but in JSP
u dont need to write whole name.

Is This Answer Correct ?    2 Yes 2 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / fazal

1)A JSP is typically oriented more towards displaying
information, and a servlet is more oriented towards
processing information. For example, a JSP might display a
report, while a servlet would process a user submitted
form. These uses are not exclusive, but they are optimized
more for performing tasks in this manner. It is much easier
to incorporate HTML coding into a JSP than a Servlet. It is
also easier to write more complex Java code in a servlet.

2)JSP has Implicit objects and Servlets do not.
3)JSP and Servlet both define the server end functionality
to provide dynamic outputs ,As we know our HTML is only the
client end technology version which runs on client browser.
JSP and Servlet differ each other in terms of represntation
and execution cycle. Servlet are full functional java codes
that define the output like write to stream files in
protocol defined ways, JSP on the other hand is Role
Sepated format to do so where a ordinary web designer
designes how will be the presentation of the data and
Programmer defines the functinality to provide the
underlying things represented in conditional and non
conditinal ways , But here is the magic of JSp that merges
the both HTML represntation mixed with JAVA scriptlets.

Is This Answer Correct ?    2 Yes 2 No

what is the difference between Servlet and JSP?Advantage of JSP over Servelt?Any concept present i..

Answer / sakthi

Both Servlet and Jsp are used for webapplication
Inorder to retrive request from client side page HTML that
is retriving values then we pass on to server side page for
to make a dynamic web page so that we need a interpreter for
converting client request to java understandable format is
Servelets or jsp

Servlet is a Java Http class file while jsp is one of the
server side scripting language later on it is converted to
java class file thats it.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Servlets Interview Questions

What are advantages of servlets over cgi?

0 Answers  


What are the functions of Servlet container?

0 Answers  


Explain how does JSP handle run-time exceptions?

0 Answers   BirlaSoft,


What are the benefits of using servlet over cgi?

0 Answers  


when you comppile the servlet is it neccesary to restaet the tomcat server?

6 Answers   HCL,






How many Cookies can a host support?

2 Answers  


What are the exceptions thrown by Servlets?

4 Answers   Amplify Mindware,


Define the lifecycle for executing a jsp page.

0 Answers  


What is difference between cookies and httpsession?

0 Answers  


Explain the difference between GET and POST methods?

6 Answers  


What is a servlet?

0 Answers  


What are the uses of servlet

0 Answers  


Categories