at-m42:lecture13
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
at-m42:lecture13 [2009/04/22 07:46] – eechris | at-m42:lecture13 [2011/01/14 12:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
~~SLIDESHOW~~ | ~~SLIDESHOW~~ | ||
- | ====== Presentation | + | ====== Presentation-tier Services ====== |
* Server services is the largest market sector in Java world((Mobile may well become more important, certainly in terms of installed systems, if not in terms of monetary value, we shall see)). | * Server services is the largest market sector in Java world((Mobile may well become more important, certainly in terms of installed systems, if not in terms of monetary value, we shall see)). | ||
Line 19: | Line 19: | ||
* Despite best efforts of some, server is not a single source platform (e.g. WinTel): much more heterogeneous than the typical client (Desktop). | * Despite best efforts of some, server is not a single source platform (e.g. WinTel): much more heterogeneous than the typical client (Desktop). | ||
* The Java platform offers platform-independent server environment with developing support that allow links to “legacy” applications. | * The Java platform offers platform-independent server environment with developing support that allow links to “legacy” applications. | ||
- | * Possibly most important server application is ability to link to an SQL database: this is provided in Java by the JDBC package (see [[lecture15|Integration Tier Services]]). | + | * Possibly most important server application is ability to link to an SQL database: this is provided in Java by the JDBC package (see [[lecture14|Integration Tier Services]]). |
* Next most important is web services providing (browser based) thin-client applications for e-commerce, in institutions via the intranet and to the general public via the Internet. | * Next most important is web services providing (browser based) thin-client applications for e-commerce, in institutions via the intranet and to the general public via the Internet. | ||
Line 477: | Line 477: | ||
* Good compromise between code-only servlet and Java-rich JSP. | * Good compromise between code-only servlet and Java-rich JSP. | ||
| | ||
+ | ===== Another example ===== | ||
+ | * Example from //Groovy in Action//: [[http:// | ||
+ | * This is the // | ||
+ | |||
+ | <code groovy 1|Example 14: Controller of HighLow game (at-m42/ | ||
+ | def session = request.session | ||
+ | def guess = params.guess | ||
+ | |||
+ | guess = guess ? guess.toInteger() : null | ||
+ | if (params.restart) guess = null | ||
+ | |||
+ | if (! session.goal || params.restart) { | ||
+ | session.goal = (Math.random() * 100).toInteger() | ||
+ | } | ||
+ | def goal = session.goal | ||
+ | |||
+ | // ... | ||
+ | </ | ||
+ | |||
+ | ===== Example (continued) ===== | ||
+ | |||
+ | <code groovy 1|Example 14: view for HighLow game (at-m42/ | ||
+ | // ... | ||
+ | |||
+ | html.html { head { title 'Think of a Number' | ||
+ | body { | ||
+ | h1 'Think of a Number' | ||
+ | if (goal && guess) { | ||
+ | div "Your guess is $guess " | ||
+ | if (guess == goal) { | ||
+ | div ' | ||
+ | } else if (guess < goal) { | ||
+ | div 'too low' | ||
+ | } else { | ||
+ | div 'too high' | ||
+ | } | ||
+ | } | ||
+ | p " | ||
+ | form(action : ' | ||
+ | input (type : ' | ||
+ | button (type : ' | ||
+ | button (type : ' | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
===== Adding GSP capabilities to Servlet container ===== | ===== Adding GSP capabilities to Servlet container ===== | ||
+ | <code xml 1> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== A GSP View Page ===== | ||
+ | |||
+ | <code html l|Example 15(a): View for High-Low Game (at-m42/ | ||
+ | extern> http:// | ||
+ | </ | ||
+ | |||
+ | ===== The Controller: Dispatches to View ===== | ||
+ | |||
+ | * Revised controller Groovlet: [[http:// | ||
+ | <code groovy l|Example 15(b): Controller which dispatches to view (at-m42/ | ||
+ | extern> http:// | ||
+ | </ | ||
===== Other Examples of Template View implementations ===== | ===== Other Examples of Template View implementations ===== | ||
- | Not for discussion here … to be studied as part of your seminar project. | + | * Not for discussion here. |
- | Java standard is to use “custom tags” that talk to Java classes. | + | |
- | Tags look like XML tags (with namespaces) in (X)HTML pages | + | |
- | JSTL – Java Standard Tag Library provides access to beans and provides simple programming logic tags. | + | |
- | Can eliminate <% … %> from JSP code! | + | |
- | Several open source alternatives: | + | |
- | Best regarded seems to be Velocity (another | + | * Best regarded seems to be // |
- | Very simple template language embedded in HTML | + | * Very simple template language embedded in HTML -- similar to GSP |
- | Parsed and replaced by computational results (by a special Servlet) at access time. | + | * Parsed and replaced by computational results (by a special Servlet) at access time. |
- | Transparent to web developers who just see HTML pages. | + | * Transparent to web developers who just see HTML pages. |
===== Lecture Contents ===== | ===== Lecture Contents ===== | ||
Line 552: | Line 622: | ||
===== MVC Frameworks ===== | ===== MVC Frameworks ===== | ||
- | Many common problems (as indicated by the large number of patterns for presentation tier) have been solved many times. | + | * Many common problems (as indicated by the large number of patterns for presentation tier) have been solved many times. |
- | Many frameworks have been developed to simplify and standardise web tier development and implement the patterns. | + | |
- | All based around Servlets. Some also use or extend JSP. | + | |
- | Some examples (study for seminar): | + | |
- | Front Controller: | + | |
- | Apache Struts: http:// | + | |
- | Spring MVC: http:// | + | |
- | Component model: | + | |
- | Jakarta Tapestry: http:// | + | |
- | Java EE JavaServer Faces (JSF): http:// | + | |
- | + | ||
- | + | ||
- | Lecture Summary | + | |
- | Advantage of Java web container is that it is platform independent: | + | |
- | We have introduced some of the Java APIs that can be used to create web-based presentation services with Java. | + | |
- | Servlets provide a way to create applications that communicate to a client via a web browser. | + | |
- | JSP allows the embedding of Java code inside an HTML page. | + | |
- | In the thin-client world you are not working alone! | + | |
- | Several core Java EE design patterns record best practice and have been implemented in open source and official Java solutions. | + | |
- | + | ||
- | Lab Exercises | + | |
- | Download, install and run Tomcat | + | |
- | Modify ServletsRule.java so that the count i is loaded when the servlet starts (override init()) and is saved to disk by an overriden destroy() method. | + | |
- | Experiment with JSP pages. | + | |
- | Read-up on any or all of the Java EE patterns concerned with the presentation tier. | + | |
- | Look into alternative presentation tier technologies: | + | |
+ | ===== Some Example Frameworks ===== | ||
+ | //Front Controller//: | ||
+ | * Apache Struts: http:// | ||
+ | * Spring MVC: http:// | ||
+ | //Component model//: | ||
+ | * Apache Tapestry: http:// | ||
+ | * Java EE JavaServer Faces (JSF): http:// | ||
+ | * Google Web Toolkit (GWT): http:// | ||
+ | Many more [[http:// | ||
+ | ===== Lecture Summary ===== | ||
+ | * Advantage of Java web container is that it is platform independent: | ||
+ | * We have introduced some of the Java APIs that can be used to create web-based presentation services with Java. | ||
+ | * Servlets provide a way to create applications that communicate to a client via a web browser. | ||
+ | * JSP allows the embedding of Java code inside an HTML page. | ||
+ | * Groovy makes both Servlets (Groovlets) and Templates (GSP) easier. | ||
+ | * In the thin-client world you are not working alone: | ||
+ | * Several core Java EE design patterns record best practice and have been implemented in open source and official Java solutions. | ||
---- | ---- | ||
[[Home]] | [[lecture12|Previous Lecture]] | [[Lectures]] | [[lecture14|Next Lecture]] | [[Home]] | [[lecture12|Previous Lecture]] | [[Lectures]] | [[lecture14|Next Lecture]] | ||
- |
at-m42/lecture13.1240386392.txt.gz · Last modified: 2011/01/14 12:23 (external edit)