Results 1 to 6 of 6

Thread: Servlet vs JSP

  1. #1
    javaplus is offline Member
    Join Date
    Nov 2007
    Posts
    97
    Rep Power
    0

    Default Servlet vs JSP

    I am exploring J2EE. I have basic knowledge of JSP and Servlets but I am confused when to use what. What I know is, what we can do iwit JSP, can also be done with Servlets. So when to use what?

    Is there any performance issue related?

    Thanks in advance.

  2. #2
    Shahid is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    Default

    JSP allows you to embed java code in the HTML.thus, u can create the webpage using the HTML coding and use java code to handle the logic wherever required.

    Servlet doesnt allow u to embed java code in the HTML. Servlet is saved as a separate file, and can be accessed from the HTML document.

  3. #3
    wsaryada is online now Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default

    For the basic rule use JSP for the presentation layer where the data should be displayed and it will look, etc. And the servlet is use for a controller to your web application, take a request from user; for instance a JSP page; get the submitted data and save it to the database.

  4. #4
    Join Date
    Apr 2008
    Posts
    64
    Rep Power
    0

    Default

    hi,
    jsp page wen compiled, ll become a servlet only.. and in servlet also u can embed html codes...
    use jsp for design
    and servlet for bussiness logic......
    regards

  5. #5
    javarishi is offline Member
    Join Date
    Apr 2008
    Posts
    91
    Rep Power
    0

    Default

    Hei,
    Both JSP And Servlet Are ServerSide Components For Serving

    Http Requests. But The Purpose Is Defferent.

    Use Jsp Wherever you want to display some data to User as

    UserInterface. jsp will be used for presentation logic.

    Servlet Can Be Used To Implement Controller Logic. That Is to

    implement the request-response flow scenarios in your application.

  6. #6
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Servlets came first. They are just java classes that inherit from some useful base classes can can easily read parameters from a GET/POST command and can write a response to the user/client's browser.

    JSP is a way to have something look mostly like HTML interact with servlets.

    Anything you can do with JSP pages, you can do by hand with servlets. But JSP makes it easier, and you can use WYSIWYG tools like Dreamweaver to make a jsp page.

    And you don't need J2EE all all its evil overhead to use jsp pages and servlets.

Similar Threads

  1. my first servlet
    By sireesha in forum Java Servlet
    Replies: 3
    Last Post: 04-09-2008, 03:11 PM
  2. Regarding Servlet
    By Sudha in forum New To Java
    Replies: 1
    Last Post: 02-12-2008, 12:44 AM
  3. JSP or Servlet
    By ravian in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-03-2007, 03:00 PM
  4. How to mix servlet & JSP
    By Swamipsn in forum Java Servlet
    Replies: 1
    Last Post: 08-08-2007, 12:57 AM
  5. Replies: 1
    Last Post: 08-07-2007, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •