Two Laptop Bag*
The moose likes Servlets and the fly likes Do you know this? Click Here Now. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Do you know this? Click Here Now." Watch "Do you know this? Click Here Now." New topic
Author

Do you know this? Click Here Now.

MDS Gill
Greenhorn

Joined: Dec 29, 2002
Posts: 2
Can someone please clearly define the distinction between JSP, Java Servlets?

I'd like to know their specific use and role for developing distributed applications and how each one is used?
How does JDBC fit in there? Which database is used, Oracle?
Thanks in Advance!!
Marty Hall
Author
Ranch Hand

Joined: Jan 02, 2003
Posts: 111
Can someone please clearly define the distinction between JSP, Java Servlets?

At first blush, things look like this:
  • A servlet is a Java program that has HTML inside it (in print statements)
  • A JSP document is an HTML page with Java code

  • inside it (marked by special tags)

    Now, this is a great oversimplification, but the basic idea is that a servlet looks like a regular Java class whereas a JSP document usually looks more like an HTML page. Behind the scenes, though, there are only servlets: JSP documents are just alternative ways of writing servlets, JSP documents get translated into servlets, and at request time there are only servlets.
    Since JSP documents get translated into servlets, a servlet could do anything a JSP page could do. But that does not mean they are equally convenient, equally productive, equally maintainable, or equally applicable to all circumstances. When to use servlets, when to use JSP, and when to use a combination of the two (via the MVC architecture) is a long and complicated discussion, but the gist of the idea is that servlets are better at data processing and business logic, whereas JSP is better at presentation.
    How does JDBC fit in there? Which database is used, Oracle?

    JDBC is an API that standardizes the way to connect to a relational database from a Java program and standardizes the data structure that results from a query. You can use JDBC to talk to Oracle, DB2, Sybase, SQL Server, Informix, MySQL, MS Access, and zillions of other databases.
    For lots of detail on servlets, JSP, and JDBC, you can see the free online version of Core Servlets and JSP at http://pdf.coreservlets.com/.
    Cheers-
    - Marty


    Java training and consulting
    MDS Gill
    Greenhorn

    Joined: Dec 29, 2002
    Posts: 2
    Thanks Marty!
    Keep em coming boys!
    Simon Brown
    sharp shooter, and author
    Ranch Hand

    Joined: May 10, 2000
    Posts: 1913
        
        6
    Good timing - I've just covered some of this in my new article for the JavaRanch newsletter.
    Simon
     
    wood burning stoves
     
    subject: Do you know this? Click Here Now.
     
    Similar Threads
    EJB version
    Bad version of the Servlet class
    Number of Threads
    memory usage
    importance of main method in servlets