OOSSE - OO Review Review session A review of other OO technologies and may be useful for exam (not required for assignment) OO web development philosophy.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Java Script Session1 INTRODUCTION.
Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.
Apache Struts Technology
Java II--Copyright © Tom Hunter. J2EE JSP Custom Tag Libraries.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
JSP Tag Extensions And Java Bean. JSP Tag Extensions Tag extensions look like HTML (or rather, XML) tags embedded in a JSP page. They have a special meaning.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
Generate Dynamic Content On Cache Server Master’s Project Proposal by Aparna Yeddula.
DT228/3 Web Development JSP: Directives and Scripting elements.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Apache Struts Technology A MVC Framework for Java Web Applications.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Java for the WWW November 2012Slide Tag Libraries What are they? –Custom libraries Custom tags – see examples in following slides.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
1 JSP with Custom Tags Blake Adams Introduction Advanced Java Server Pages – Custom Tags Keyterms: - Tag Library Descriptor(TLD) - Tag Libraries.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Writing Enterprise Applications with J2EE (Fourth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
JSP Tag Libraries Lec Last Lecture Example We incorporated JavaBeans in “Course Outline” Example But still have to write java code inside java.jsp.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
JSP Custom Tags. Prerequisites Servlet API Mapping to JSP implicit objects JavaServer Pages Basic syntax Implementation via servlet API XML.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
OOSSE Week 8 JSP models Format of lecture: Assignment context JSP models JSPs calling other JSPs i.e. breaking up work Parameter passing JSPs with Add.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
® IBM Software Group © 2007 IBM Corporation JSP Tag Files
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
J2EE JSP Custom Tag Libraries 1 3 JSP: Custom Tag Libraries.
Apache Struts Technology A MVC Framework for Java Web Applications.
Design and Maintenance of Web Applications in J2EE
MSIS 655 Advanced Business Applications Programming
J2EE Lecture 1:Servlet and JSP
Presentation transcript:

OOSSE - OO Review Review session A review of other OO technologies and may be useful for exam (not required for assignment) OO web development philosophy JSP and OO MVC models review Struts Tag libaries Ajax Summary Slide 1 Source:

OOSSE - OO Review OO Software Engineering By now you have experienced UML JSP Let us review the OO tenets (beliefs, principles) and how JSP reflects these tenets What are the tenets of OO? Version 1.1 Dec 2008 Slide 2 Source:

OOSSE - OO Review UML for web development Can we also reflect on this? How does UML help in web development What diagrams have been useful? What else is available from UML? Answer: Web Application Extensions (WAE) A set of UML modelling aspects designed to help the web developer model web applications Reading herehere Version 1.1 Dec 2008 Slide 3 Source:

OOSSE - OO Review JSP engine reviewed The JSP engine builds a servlet. The HTML portions of the JavaServer Page become Strings transmitted to print methods of a PrintWriter object. The JSP tag portions result in calls to methods of the appropriate class whose output is translated into more calls to a println method to place the result in the HTML document. Version 1.1 Dec 2008 Slide 4 Source:

OOSSE - OO Review JSP engine reviewed JSP actually supports real Java code, not a new scripting language. Java code inside JSP is added to methods of a Java Servlet that are generated the first time the JSP is requested. Uses set of pre-established objects by the Web server that they use to generate a dynamic Web page. Version 1.1 Dec 2008 Slide 5 Source:

OOSSE - OO Review OO web development philosophy Web development... A collection of individual objects, that act on each other Different from traditional view in which a program may be seen as a collection of actions, or simply as a list of instructions Objects capable of receiving messages, processing data, and sending messages to other objects New object that inherits features from existing objects What we are seeing is a move from scripting/HTML websites to a more OO philosophy Version 1.1 Dec 2008 Slide 6 Source:

OOSSE - OO Review JSP Model 1 architecture JSPs to handle HTTP requests Data layer via Java Beans For small web applications this model is okay but more complex commercial applications a different model is required – Model 2 Version 1.1 Dec 2008 Slide 7 Source:

OOSSE - OO Review Version 1.1 Dec 2008 Slide 8 Source:

OOSSE - OO Review JSP Model 2 architecture Also called Web Model-View-Controller (MVC) design see next slide Separates the GUI from the business layer Uses a Java Servlet to receive the HTTP requests from the browser and communicate with the model layer JSPs only used for presentation – the Servlet determines which view to send back to the client Version 1.1 Dec 2008 Slide 9 Source:

OOSSE - OO Review Version 1.1 Dec 2008 Slide 10 Source:

OOSSE - OO Review Servlets - “nuts and bolts” The Servlet class extends the HttpServlet class Essentially this means it can use the attributes/methods of this class The HttpServlet class has a number of methods an init( ) method - used for connecting to databases dsn’s it has service method e.g. doGet, doPost, doPut and doDelete the above methods are the “meat” of the HttpServlet class It uses two objects, namely HttpServlet Request and HttpServlet Response Here is an example of the MVC approach link Version 1.1 Dec 2008 Slide 11 Source:

OOSSE - OO Review Other technology - Apache Struts Interesting web architecture framework Designed to handle requests made by the client or by web browsers Apache struts is an open source framework using servlet and JSP See next slide for picture of struts Version 1.1 Dec 2008 Slide 12 Source:

OOSSE - OO Review Version 1.1 Dec 2008 Slide 13 Source:

OOSSE - OO Review Other technology - Tag Libaries Custom tags are dynamic page elements. This means they can provide functionality to a webpage using a syntax similar to normal HTML tags. The functionality is up to you… They can provide an alternative (or an additional) mechanism to JavaBeans for dynamic scripting As an example see this link JSP Controls Version 1.1 Dec 2008 Slide 14 Source:

OOSSE - OO Review What do you need? There are two components to a tag: A Java tag handler class that implements the tag’s functionality. A Tag Library Descriptor (TLD) in the form of an XML file describing the tag. By including this tag on a JSP page you have access to its functionality. Version 1.1 Dec 2008 Slide 15 Source:

OOSSE - OO Review Java handler class Yes, you have to code the functionality in Java. So why bother? Why not just create a JavaBean instead? For standard webpage scripters, tags are more familiar and provide a simpler mechanism. For web application developers, JavaBeans integrate more fully with the full application environment so are more powerful. Your choice…. Version 1.1 Dec 2008 Slide 16 Source:

OOSSE - OO Review Making the handler You Java class needs to extend the TagSupport class. This class is only available in the Enterprise version of the Java Development Kit (from version 1.3.1). Or, the Java Web Services Developer Pack. These are free of course… However, you just need the lib/j2ee.jap file (in the case of J2EE) or the lib/servlet.jar for the JWSDP. You can then extract the javax.servlet.jsp.tagext class from the.jar file (using WinZip etc.) and put it into folder containing your tag classes. Version 1.1 Dec 2008 Slide 17 Source:

OOSSE - OO Review package yvanstags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; public class HelloWorld extends TagSupport { public int doStartTag() { try { JSPWriter out = pageContext.getOut(); out.print(“HelloWorld”); } catch(IOException ioe) { System.out.println(“Error: “ + ioe.getMessage()); } return SKIP_BODY; } Version 1.1 Dec 2008 Slide 18 Source:

OOSSE - OO Review Making the handler Once you have your custom tag Java code, you need to compile it and put the resultant.class file in your WEB-INF/classes folder. For the HelloWorld example, this would go in: WEB-INF/classes/yvanstags Next you need the descriptor… Version 1.1 Dec 2008 Slide 19 Source:

OOSSE - OO Review Tag Library Descriptor A TLD is a (fairly) simple XML file that describes a set of custom tags. You can put as many or as few custom tags in a TLD and more than one TLD can be used in a single project. In principle, you could create many useful tags and zip them into one.jar file for easy resusability. Version 1.1 Dec 2008 Slide 20 Source:

OOSSE - OO Review Tag Library Descriptor <!DOCTYPE taglib PUBLIC “-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN” mytaglibs Yvan’s Tag Library helloworld yvanstags.HelloWorld empty Display Hello World greeting message Version 1.1 Dec 2008 Slide 21 Source:

OOSSE - OO Review Using your custom tag To use your custom tag, you need a JSP page. You need to tell your JSP where to find your tag library so you use a page directive: Anywhere in your JSP page, you can then use your custom tag(s): Version 1.1 Dec 2008 Slide 22 Source:

OOSSE - OO Review JSP custom tag example Tag Library Test Custom tag output: Version 1.1 Dec 2008 Slide 23 Source:

OOSSE - OO Review Easy tagging The previous method for utilising tag libraries works fine… if you can get your tags to compile. From Tomcat version 5, there is a much simpler method for custom tags. This simpler method does not require any compilation (we just use standard JSP) but there are some rules. Version 1.1 Dec 2008 Slide 24 Source:

OOSSE - OO Review A simple tag For the display of static/dynamic text, you can create a piece of JSP code. This file needs to be named with a.tag suffix and placed in a folder called tags in your WEB- INF area. Tomcat 5+ will then be able to use your tag from within your normal JSP files using the same mechanism as before. Here’s an example for displaying the date… Version 1.1 Dec 2008 Slide 25 Source:

OOSSE - OO Review dateTag.tag code <% DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG); Date now = new Date(System.currentTimeMillis()); out.println(dateFormat.format(now)); %> Note: there is no page directive for tags, however, there is a tag directive that works in a similar manner. Version 1.1 Dec 2008 Slide 26 Source:

OOSSE - OO Review date.jsp code Today is Version 1.1 Dec 2008 Slide 27 Source: Call the tag code using your prefix and the filename you used for the tag. Specify a shorthand name in the prefix attribute for the tags folder.

OOSSE - OO Review Directives DirectiveDescription tag This directive is similar to the page directive for JSP pages. include Use this directive to include other resources from the tag file. taglib Use this directive to use a custom tag library from inside of the tag file. attribute Use this directive to declare an attribute in a tag file. variable Use this directive to define a variable that you can expose to the calling JSP page. Version 1.1 Dec 2008 Slide 28 Source:

OOSSE - OO Review Tag directive attributes AttributeDescription body-content The information about the body content of this tag. The value can be empty, tagdependent, or scriptless (default). dynamic-attributes Indicates support for dynamic attributes. The value identifies a scoped attribute in which to place a Map containing the names and values of the dynamic attributes passed during this invocation. import Used to import a class or an interface or all members of a package. The same as the import attribute in the page directive. Version 1.1 Dec 2008 Slide 29 Source: Note: only the import attribute can appear more than once.

OOSSE - OO Review Other technology - Ajax AJAX, shorthand for Asynchronous JavaScript and XML exchanging small amounts of data with the server behind the scenes Speeds up web interaction Version 1.1 Dec 2008 Slide 30 Source:

OOSSE - OO Review Version 1.1 Dec 2008 Slide 31 Source:

OOSSE - OO Review Summary Doing development in an OO style is beneficial even if the software being used is not directly OO For the enterprise level OO is evident in the selection of technologies mentioned Version 1.1 Dec 2008 Slide 32 Source: