- World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.

  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!

    Send your Resume to 6000 Companies

    Question :
    What is the difference between servlets and jsp?

    Posted by: Mk on 11/18/2007

    Contact Mk Contact Mk
    Category Servlet Interview Questions
    Rating (0.4) By 1530 users
    Added on 11/18/2007
    Views 4487
    Rate it!

    In servlet,java will be used to generate dynamic HTML pages,but in JSP,java will be reduced and we can use our custom tags to generate HTML pages.

    Posted by: olymohamed    

    Contact olymohamed Contact olymohamed

    In servlet if any change in your class file you must redeploy again but jsp only one you have to deploy. in compare to servlet jsp reduce code and contains implicit objects.

    Posted by: chitra    

    Contact chitra Contact chitra

    What is the difference between servlets and Java Server Pages? Which is preferred?
    Servlets and Java Server Pages are complementary APIs, both providing a means for generating dynamic Web content. A servlet is a Java class implementing the javax.servlet.Servlet interface that runs within a Web or application server's servlet engine, servicing client requests forwarded to it through the server. A Java Server Page is a slightly more complicated beast. JSP pages contain a mixture of HTML, Java scripts (not to be confused with JavaScript), JSP elements, and JSP directives. The elements in a Java Server Page will generally be compiled by the JSP engine into a servlet, but the JSP specification only requires that the JSP page execution entity follow the Servlet Protocol.

    The advantage of Java Server Pages is that they are document-centric. Servlets, on the other hand, look and act like programs. A Java Server Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside an HTML template file and are primarily used to generate dynamic content. Some of the JSP functionality can be achieved on the client, using JavaScript. The power of JSP is that it is server-based and provides a framework for Web application development. Rather than choosing between servlets and Java Server Pages, you will find that most non-trivial applications will want to use a combination of JSP and servlets. In fact, the JSP 1.1 and Servlet 2.2 specifications are based around the concept of the Web application, combining the two APIs into a unified framework.

    Posted by: hariharan    

    Contact hariharan Contact hariharan

    (1)Bits of HTML embedded in java code.(2) Suitable for coding business layer of enterprise application.(3)Created and maintained by Java programmers

    (1) Bits of java code embedded in HTML.
    (2)Suitable for coding presentation layer of enterprise application
    (3)Created and maintained by Web designers.

    Posted by: Margi Pancholi    

    Contact Margi Pancholi Contact Margi Pancholi

    JSP page has both presentation logic and business logic but servlet has only business logic and presentation logic is present in html file

    Posted by: sai    

    Contact sai Contact sai

    Jsp is nothing but a servlet.jsp is transfered to servlet by jsp engine.after converting it acts like a servlets static content and dynamic content are combined.we can avoid this using jsp.we can separate static content from dynamic this makes the application very flexible.

    Posted by: ranjith    

    Contact ranjith Contact ranjith

    servlets will allow only java code ie other than java code like html,javascript can be written in out.println()statements only.but,jsp allows us code other than java also.jsp dirctly allows us to write templet text,scripts,jstl,java code

    Posted by: ranjith    

    Contact ranjith Contact ranjith

    In jsp html pages with javacode embedded inside of them.In servlets java programs with html embedded inside of them.

    Posted by: priya.s    

    Contact priya.s Contact priya.s

    In servlet java code can't embedded wih servlet's custome tag.
    In jsp java code can embedded with jsp's custome tag

    Posted by: Baskar    

    Contact Baskar Contact Baskar

    JSP contains more static content and less dynamic content but servlet contains more dynamic and less static content.

    Posted by: muthu    

    Contact muthu Contact muthu

    Servlet contains very indepth coding to develop any servlet web application.And also all logics are implemented in same servlets we get page centric problem.There is no implicits objects and by default servlet is not a threadsafe.It is not participating session by default.javax.servlet package.

    when compare to servlets....
    In jsp,Indepth java coding is reduced because of custom tags is used.And Business,Data acess logics are developed in different webpages.It means presentation logics are developed in jsp page and data acess logic developed in JavaBean class.It eliminates pagecentric problem. Jsp have its own implicit objects provided by container.Bydefault its participating in session.It is the subpackage of javax.servlet.jsp package.But both are available in same server.

    Posted by: venkateswara reddy gunapati    

    Contact venkateswara reddy gunapati Contact venkateswara reddy gunapati

    servlet:-1)mainly for business logic.
    2)once compled a servlet,if any modifications then once again complie and re-deploy.
    3)no implicit objects.

    jsp:-1)mainly for presentation logic.
    2)want to make changes go to the source jsp file and make changes,not need any recompilation.
    3)implicit objects are there.

    **** jsp== servlet ****

    because,even if u write any jsp file at the back a servlet will be generated.
    (for example if u r using tomcat as server then in "work directory "of tomcat there u can find the servlet.

    Posted by: M.Santosh Kumar    

    Contact M.Santosh Kumar Contact M.Santosh Kumar

    servlet is runs on the server.It has only business logic. jsp is mixing of html and java.
    JSP page has both presentation logic and business logic.

    Posted by: Rahman khan    

    Contact Rahman khan Contact Rahman khan

    JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only supported protocol in JSP is HTTP. But a servlet can support any protocol like HTTP, FTP, SMTP etc.

    Posted by: Sanjay Deorari    

    Contact Sanjay Deorari Contact Sanjay Deorari

    servlet is html with in java where as jsp is java within html. so it is easy to write the jsp code.

    . servlet is compiled language where as jsp is interprited language.

    Posted by: yaser    

    Contact yaser Contact yaser

    The main difference between servlets and jsp is that servlets support all protocols while jsp supports only HTTP protocol.

    Posted by: Sahiti    

    Contact Sahiti Contact Sahiti

    Servlet is the java code inside HTML
    where as JSP is the HTML inside java code..........

    Posted by: janardan    

    Contact janardan Contact janardan

    to develop a servlet, a programmer should known the complete knowledge on java but where as to develope a jsp a little bit of knowledge is enough because custom tags make the work easy and allows the developer and user make the code to understand easy

    Posted by: KISHORE    

    Contact KISHORE Contact KISHORE

    servelet and java server pages are complementary API's.both providing a means for generating dynamic web content...

    Posted by: mahesh    

    Contact mahesh Contact mahesh

    I would prefer servlet cos jsp are slower than servlets as they are first required to converted in java code and then serv to the users.

    Posted by: Piyush    

    Contact Piyush Contact Piyush

    jsp is nothing but a pre-compiled servlet .

    Posted by: Thanuja    

    Contact Thanuja Contact Thanuja

    jsp is by default Thread safe and servlet is by default not threadsafe . Jsp have separate area to Business and presentation logic,but in servlet at same area provide both logics(business and presentation)

    Posted by: Nag    

    Contact Nag Contact Nag

    servlet: its a java class so for every change we have to
    compile the code to reflect the change.Mainly using for
    writing business logics.

    jsp:its a file, its automatically converted into a servlet
    on deploying. We can't compile it explicitly.the changes
    will get reflect by saving the file.Its mainly used for
    presentation of data

    Posted by: MANISH Kumar    

    Contact MANISH Kumar Contact MANISH Kumar

    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

    Related Questions
    View Answer
    how do you compile servlet program?
    View Answer
    Why init is used and not constructor for servlets initialization?

    View Answer
    How can we refresh the servlet for every 2 minutes automatically?

    View Answer
    What is servlet ,what is the use of it?

    View Answer
    How can a web container know whether cookies are accepted or not accepted by the browser

    View Answer
    What is pure servlet?

    View Answer
    What is the diff b/w doGet() and service() method?

    View Answer
    When destroy method get call, will it call for each user please give the ans in detail?

    View Answer
    Can we use any other technology than JSP to construct a view ?

    View Answer
    When we are saving form bean ,What is the difference between session scope and request scope.

    View Answer
    How to build struts in java?
    What are the function of struts?

    View Answer
    How can i pass info from dyna form bean to Entity Bean(CMP)

    View Answer
    What is the actual difference between MVC and MVC Model2

    View Answer
    In which pattern does all the action classes in the struts are organized

    View Answer
    What is the use of findbyprimarykey()?

    View Answer
    What is difference between Design Pattern and FrameWork.

    View Answer
    What is the difference between servlet context and servlet config

    View Answer
    Whats meant by struts?how to use struts in IBM websphere appli. ?
    and how to managed with struts?(plz answer simply just an intro. don't go very deep)

    View Answer
    I have linux OS.I installed Tomcat 4. in Linux.
    Now, i have to deploy My web application into that using WAR

    Please tell me steps....and also steps for the creating the WAR file too.

    View Answer
    What is the difference between Apache struts and Jakarta Struts?? why there are 2 names??

    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here - Best Freshers & Experienced Jobs Website.

    View ALL Servlet Interview Questions

    User Options
    Sponsored Links

    Copyright ©2003-2015, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Cache = 0.109375 Seconds