Chapter 1: JSP Overview - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Chapter 1: JSP Overview

Description:

CGI, ASP, and ASP.NET. CGI. Compiled, runs fast. Difficult to ... Read J2EE Overview: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview.html#wp80172 ... – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 21
Provided by: conest
Category:

less

Transcript and Presenter's Notes

Title: Chapter 1: JSP Overview


1
Chapter 1JSP Overview
Reference Beginning JSP
2
Objectives
  • To learn
  • Relative advantages of using JSP
  • Vendors and platforms supporting JSP
  • Steps in servlet development
  • Why use JSP
  • Apache Tomcat 5.5

3
A Brief History of the Java Platform
  • 1995 Version 1.0 (Sun Microsystems)
  • 1997 Version 1.1
  • 1998 Java 2 platform
  • 1999 J2SE, J2EE, and J2ME
  • 2001 Version 1.3 of J2SE
  • 2002 Version 1.4 of J2SE
  • 2002 Version 1.3 of J2EE (JSP 1.2)
  • 2004 Version 1.4 of J2EE (JSP 2.0)

4
The Three Editions of the Java 2 Platform
  • The Java 2 platform comes in three versions
  • Java 2 Standard Edition (J2SE)
  • Java 2 Enterprise Edition (J2EE)
  • Java 2 Micro Edition (J2ME)

5
JSP is a part of J2EE
  • J2EE
  • A set of integrated Java APIs that enable
    client-server Web applications
  • Originally defined by Sun Microsystems
  • Java Community Process now includes many software
    vendors including IBM, BEA, etc.
  • J2EE is not the same as J2SE
  • J2EE has many versions
  • J2EE 1.2
  • J2EE 1.3
  • J2EE 1.4 (used in this course)
  • JSP 2.0, Servlet 2.4

6
Products (Web containers) that support JSP
2.0/Servlet 2.4
  • Apache Tomcat 5.5
  • used in this course
  • JBoss 4.0
  • Sun Application Server 8.1
  • IBM WebSphere 6.0
  • BEA Weblogic 9.0
  • Etc.

7
Reasons for Using J2EE
  • Hardware Independence
  • Works with different hardware and software
    platforms
  • http//java.sun.com/j2ee/compatibility.html
  • Code Separation
  • Layered architecture, MVC
  • Compatibility
  • different versions of APIs work together
  • Scalability
  • Pluggable components multiple servers
  • Tool Independence
  • Multiple vendors to choose from

8
Web ApplicationUsing Servlets and JSPs
  • JSP Model 2 (MVC Pattern)

Servlets
HTML/Web Browser
HTTP Request
JavaBeans
HTTP Response
JSPs
Client
J2EE Server (Tomcat 5.5)
Database (MySQL)
9
J2EE Architecture
Source Sun Microsystems
10
Key J2EE APIs
  • Component Technologies
  • Servlets
  • Java Server Pages (JSP)
  • Enterprise Java Beans (EJB)
  • Standard Services
  • Java Database Connectivity (JDBC API)
  • Java Naming and Directory Interface (JNDI)
  • Java Transaction API (JTA)
  • Other Services
  • HTTP, HTTPS, RMI-IIOP, JMS, JavaMail

11
JSP Example
  • lt_at_ taglib prefix"tags" tagdir"/WEB-INF/tags"
    gt lthtmlgt
  • ltheadgt
  • lttitlegtJSP 2.0 Examples - Hello World Using a Tag
    Filelt/titlegt
  • lt/headgt
  • ltbodygt
  • lth1gtJSP 2.0 Examples - Hello World Using a Tag
    Filelt/h1gt lthrgt
  • ltpgt lttagshelloWorld/gt.lt/pgt
  • lt/bodygt
  • lt/htmlgt

12
Dynamic Web Pages with JSP
  • JSP is a server-side scripting language that
    produces Web pages that can be viewed with any
    browser
  • You can mix regular HTML tags with JSP script in
    the same JSP page
  • The JSP scripts, if any, are interpreted by the
    application server
  • The content generated by the execution of JSP
    code is mixed with HTML code and the whole
    content is sent to the client browser

13
JSP versus HTML
  • JSP can perform the following tasks
  • Connect to and manipulate a database.
  • Create pages that can display things which will
    be of interest to a particular user.
  • Collect data from users and return information to
    a visitor based on the data collected.
  • Modify the content of a Web page, by updating a
    text file or the contents of a database rather
    than the HTML code itself.
  • Access file systems via the Internet so that you
    can read, write, and update files.
  • Utilize extensive Java Applications Programming
    Interface.

14
CGI, ASP, and ASP.NET
  • CGI
  • Compiled, runs fast
  • Difficult to modify and update
  • Not convenient to connect to database
  • ASP
  • Mix ASP script with HTML
  • Using Active control and DLL
  • ASP script itself needs to be interpreted every
    time it is requested
  • ASP.NET
  • Overcome all drawbacks discussed above
  • Drawback only supported on Windows platform

15
Servlets
  • Servlets are small Java programs that run on a
    Web server in response to client requests
  • Servlets generate dynamic content that is sent
    back to client
  • Servlets are compiled and represented as .class
    files
  • Servlets are loaded either on demand or by the
    server at start-up
  • When a servlet is requested from client, a method
    or function is called in response to the request

16
Steps in Servlet Development
  • Write / edit Java servlet code
  • repeated use of PrintWriter.println() to generate
    HTML output (e.g., out.println(lttitlegtJSP
    2.0lt/titlegt)
  • Compile servlet
  • Deploy to servlet container (e.g., Tomcat 5.5)
  • Test via browser and server
  • If tests not ok, repeat the above steps
  • Major Drawback Need to modify Java code every
    time a change is needed in the presentation code.

17
Why Use JSP
  • JSP is built on top of servlets, so it has all
    the advantages of servlets
  • JSP is compiled into its corresponding servlet
    when it is requested the first time
  • The servlet stays in memory, speeding response
    times
  • Extensive use of Java API (Applications
    Programming Interface) for networking, database
    access, distributed objects, and others like it
  • Powerful, reusable and portable to other
    operating systems and Web servers

18
Steps in JSP Development
  • Write / edit JSP page
  • Java code embedded in HTML
  • Deploy to JSP engine (servlet container )
  • e.g., Tomcat 5.5
  • Test via browser and server
  • If tests not ok, repeat the above steps
  • Advantage No need to manually compile the JSP
    page.

19
Apache Tomcat 5.5
  • Open-source (free)
  • Very popular servlet container and JSP engine
  • Runs on many platforms including Windows and
    Linux
  • Implemented the latest servlet and JSP
    specifications (servlet 2.4 and JSP 2.0)
  • Supported by the popular Java/J2EE IDE such as
    Eclipse/IBM WSAD, JBuilder, NetBeans, JDeveloper
  • Easy to deploy and administer using Tomcat Manager

20
Next Steps
  • Do
  • Lab 1 Start/ stop Tomcat 5.5
  • Lab 2 NetBeans 5.5 with bundled Tomcat 5.5.
  • Optional
  • Try It Out Chapter 1 (optional)
  • Read J2EE Overview http//java.sun.com/j2ee/1.4/d
    ocs/tutorial/doc/Overview.htmlwp80172
Write a Comment
User Comments (0)
About PowerShow.com