Date post: | 27-Dec-2015 |
Category: |
Documents |
Upload: | marcus-york |
View: | 213 times |
Download: | 0 times |
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 1Source: [email protected]
OOSSE - OO Review
OO Software Engineering
By now you have experienced UMLJSP
Let us review the OO tenets (beliefs, principles) and how JSP reflects these tenets
What are the tenets of OO?
Version 1.1 Dec 2008Slide 2Source: [email protected]
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 applicationsReading here
Version 1.1 Dec 2008Slide 3Source: [email protected]
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 2008Slide 4Source: [email protected]
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 2008Slide 5Source: [email protected]
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 objectsWhat we are seeing is a move from scripting/HTML
websites to a more OO philosophy
Version 1.1 Dec 2008Slide 6Source: [email protected]
OOSSE - OO Review
JSP Model 1 architecture
JSPs to handle HTTP requestsData layer via Java BeansFor small web applications this model is okay
but more complex commercial applications a different model is required – Model 2
Version 1.1 Dec 2008Slide 7Source: [email protected]
OOSSE - OO Review
JSP Model 2 architectureAlso called Web Model-View-Controller (MVC)
design see next slideSeparates the GUI from the business layerUses 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 2008Slide 9Source: [email protected]
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 methodsan init( ) method - used for connecting to databases dsn’sit has service method e.g. doGet, doPost, doPut and doDeletethe above methods are the “meat” of the HttpServlet classIt uses two objects, namely HttpServlet Request and
HttpServlet ResponseHere is an example of the MVC approach <link>
Version 1.1 Dec 2008Slide 11Source: [email protected]
OOSSE - OO Review
Other technology - Apache Struts
Interesting web architecture frameworkhttp://struts.apache.org/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 2008Slide 12Source: [email protected]
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 2008Slide 14Source: [email protected]
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 2008Slide 15Source: [email protected]
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 2008Slide 16Source: [email protected]
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 2008Slide 20Source: [email protected]
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 2008Slide 30Source: [email protected]
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 2008Slide 32Source: [email protected]