• Save
JavaServer Pages
Upcoming SlideShare
Loading in...5
×
 

JavaServer Pages

on

  • 1,162 views

JavaServer Pages enable Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems.

JavaServer Pages enable Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems.
www.silenceit.ca

Statistics

Views

Total Views
1,162
Slideshare-icon Views on SlideShare
1,156
Embed Views
6

Actions

Likes
1
Downloads
0
Comments
0

2 Embeds 6

http://www.slideshare.net 5
http://www.slashdocs.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JavaServer Pages JavaServer Pages Presentation Transcript

    • Java Server Pages
      JSP, JSTL, and Servlets
    • Topics
      What is JSP
      What is JSTL
      What is a Servlet?
      What are Beans?
      JSP Access Models
      Benefits and Shortcomings
      Samples
      Questions / Comments
    • What is JSP?
      JavaServer Pages enable Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems.
      JSP technology enables development of Web-based applications that are platform independent.
      JSP technology separates the user interface from content generation, enabling designers to easily change the overall page layout without altering the underlying dynamic content.
    • What is JSTL?
      The JavaServer Pages Standard Tag Library (JSTL) encapsulates core functionality common to many web applications. single, standard set of tags.
      JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.
      Examples:
      1:
      <c:forEach var="item“ items="${sessionScope.cart.items}">
      <tr><td>
      <c:out value=“${item.name}”></td>
      <td><c:out value=“${item.price}”>
      </td></tr>
      </c:forEach>
      2:
      <c:choose>
      <c:when test='${param.responseText == “Fail"}'> <b>There was an error!</b>
      </c:when>
      <c:otherwise>
      Everything is great!
      </c:otherwise>
      </c:choose>
    • What is a Servlet?
      Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems
      A servlet can almost be thought of as an applet that runs on the server side--without a face.
      Servlets have access to the entire family of Java APIs, including the JDBC API to access enterprise databases.
      Servlets can also access a library of HTTP-specific calls and receive all the benefits of the mature Java language, including portability, performance, reusability, and crash protection.
      Servlet:
      package silenceit;public class Hello{  public String show(){    return ”Hello”;  }}
      JSP Page:
      <%@page import=“silenceit.hello" %>
      <html>
      <head>
      <title>
      Example of page Directive in JSP
      </title>
      </head>
      <body>
      <%
      Hello he = new Hello();
      out.print(he.show());
      %>
      </body>
      </html>
    • What are Beans?
      Java Beans are reusable components. They are used to separate Business logic from the Presentation logic. Internally, a bean is just an instance of a class with special naming conventions and characteristics.
      Bean Conventions:
      In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behavior. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans.
      The class must have a public default constructor. This allows easy instantiation within editing and activation frameworks.
      The class properties must be accessible using get, set, and other methods (so-called accessor methods and mutator methods), following a standard naming convention. This allows easy automated inspection and updating of bean state within frameworks, many of which include custom editors for various types of properties.
      The class should be serializable. This allows applications and frameworks to reliably save, store, and restore the bean's state in a fashion that is independent of the VM and platform.
      Example Bean:
      publicclassPersonBeanimplementsjava.io.Serializable {
      private String name;
      privateboolean deceased;
      /** No-arg constructor*/
      publicPersonBean() {
      }
      /** * Property */
      public String getName() {
      returnthis.name;
      }
      /** * Setter for property Name */
      publicvoidsetName(final String name) {
      this.name = name;
      }
      /** * Getter for property "deceased" * Different syntax for a boolean field (is vs. get) */
      publicbooleanisDeceased() {
      returnthis.deceased;
      }
      /** * Setter for property deceased */
      publicvoidsetDeceased(finalboolean deceased) {
      this.deceased = deceased;
      }
      }
    • JSP Access Models
      The early JSP specifications advocated two philosophical approaches, popularly known as Model 1 and Model 2 architectures, for applying JSP technology. These approaches differ essentially in the location at which the bulk of the request processing is performed
      Model 1
      Model 2
      The Model 2 architecture, shown above, is a server-side implementation of the popular Model/View/Controller design pattern. Here, the processing is divided between presentation and front components. Presentation components are JSP pages that generate the HTML/XML response that determines the user interface when rendered by the browser. Front components (also known as controllers) do not handle any presentation issues, but rather, process all the HTTP requests
      Although the Model 1 architecture is suitable for simple applications, it may not be desirable for complex implementations. Indiscriminate usage of this architecture usually leads to a significant amount of scriptlets or Java code embedded within the JSP page
    • Benefits and Shortcomings
      JSP Benefits:
      Platform and Server Independence
      Open Development Process, Open Source
      Extensible JSP Tags
      Application persistence and variable scopes
      Mature Java language
      Easier Maintenance
      Scripting languages are fine for small applications, but do not scale well to manage large, complex applications. Because the Java language is structured, it is easier to build and maintain large, modular applications with it.
      JSP technology's emphasis on components over scripting makes it easier to revise content without affecting logic, or revise logic without changing content.
      The Enterprise JavaBeans architecture encapsulates the enterprise logic, such as database access, security, and transaction integrity, and isolates it from the application itself.
      Because JSP technology is an open, cross-platform architecture, Web servers, platforms, and other components can be easily upgraded or switched without affecting JSP-based applications. This makes JSP suitable for real-world Web applications, where constant change and growth is the norm.
      Security
      Since JSP can interoperate with standard Java it has access to the underlying Java SE Platforms extensible security architecture .
      Security features — cryptography, authentication and authorization, public key infrastructure, and more.
      JSP Shortcomings:
      • Compiler Required
      • JSP Typically issues poor error reports
      • JSP Pages use more disk space then regular scripting languages
      • Need a solid knowledge of Java
      • Some simple tasks are more difficult to perform
      • Coding standards need to be diligently adhered to
      • Since java programs run in the Java Virtual Machine, they run somewhat slower then applications written in C or C++
    • Samples
      Pizzapizza.com - Food
      Tdcanadatrust.com - Banking
      Americancentury.com - Investments
      Sportsauthority.com - News
      Imagechef.com - Fun
      Stjohns.ca - Government