This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do you know this? Click Here Now.

 
MDS Gill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
     
    MDS Gill
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Marty!
    Keep em coming boys!
     
    Simon Brown
    sharp shooter, and author
    Ranch Hand
    Posts: 1913
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Good timing - I've just covered some of this in my new article for the JavaRanch newsletter.
    Simon
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic