
Application Servers G22.3033-011 Session 3 - Main Theme Page-Based Application Servers (Part II) Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences 1 Agenda Q Microsoft IIS with COM+, and ASP Environment Q Servlet and JSP Environments Q Apache TomCat Q JRun Q eXtensible Server Pages (XSP) Environment Q Apache Cocoon2 Q Summary Q Readings Q Assignment #3 2 Summary of Previous Session Q ColdFusion 5.0 Environment Q PHP 4.0.6 Environment Q XML-Based Application Servers Q Summary Q Readings Q Assignment #2 3 1 Session 2 - Review Q Application Servers for Enhanced HTML Q a.k.a., Page-Based Application Servers Q Examples: Q Macromedia ColdFusion 5.0 Server Q Microsoft IIS with ASP Q WithEnterprise Pty Ltd Tango 2000 Q etc. Q Typically less expensive than Servers for standalone use, and servers with IDEs Q Technology stays within the familiar HTML confines Q Create pages with mixture of HTML and proprietary tags or script code using (third-party) IDE, HTML editor, or plain text editor Q Application server evaluates the code upon user requests and provides HTML pages 4 Part I Microsoft IIS with COM+ and ASP Environment Also See Session 3 Handout on: “Active Server Pages” 5 Microsoft Active Platform (Logical Architecture) 6 2 Microsoft Active Platform (Features) Q Logically centralized architecture Q Physically de-centralized architecture Q Scripting Q Client-Side: Improved user interface and data validation Q Server-Side: Business rules and data access Q VBScript and JavaScript built-in support Q PerlScript support via ActiveX scripting engine (e.g., ActiveState’s) Q Ability to mix scripting languages Q Active Server Components Q Provide OS services to ASPs Q Encapsulate business rules to ease programming Q e.g., TextStream Component (FileSystem object) 7 Microsoft Active Platform (Physical Architecture) 8 Microsoft IIS with COM+/ASP Features Q IDE: Q Visual InterDev (ASP) Q Management of site development process Q Scripting Q Alternative IDEs Q Macromedia Drumbeat, Ultradev, Dreamweaver Q NetObjects Fusion Q Microsoft FrontPage 2000 Q Adobe GoLive Q Server Platforms Q Windows 2000/NT Q Use ChiliSoft for other platforms (http://www.chilisoft.net/) Q Platforms: Solaris, Linux, AIX, HP-UX, Windows Q Immunity from current IIS attacks (e.g., code red worms on Win 2000) Q Web Server: Apache, iPlanet Q Chili!Beans support for Java (similar to Microsoft with COM+ and ASP for C++) 9 3 Microsoft IIS with COM+/ASP Features Q See “Microsoft IIS, COM+, and ASP” in “Web Server Brains” Q COM+ / ASP Q Equivalent to J2EE EJB / JSP Q Included in Microsoft Windows 2000 Advanced Server Q COM+ Q Attributes (declare what runtime services are needed by the component) Q Threads and database connection pools (access via Active Data Object API) Q ASP Object Model sub-systems Q HTTP request Q COM+ transaction Q External COM+ components Q Other solution components: Q Visual Studio 6.0 Q Internet Security and Acceleration Server (ISA) Q static content caching, fault tolerance, load balancing, request handling 10 Part II Servlets and JSPs Environment Also See Session 3 Handout on: “Applets, Servlets, and Java Server Pages” “Servlets” 11 Introduction to Servlets and JSPs Q See http://www.java-shop.com/jsp.htm Q Servlets (http://java.sun.com/products/servlet/) Q Java’s standard mechanism for writing code that runs and extends the functionality of a servlet engine Q A servlet is to a server what an applet is to a browser Q HTTP servlets Q Replacement for CGI Q Standard mechanisms for handling cookies, sessions, session/application contexts Q Advantages over CGI: performance, platform and web-server independance Q Servlet filters are new in the Java Servlet Specifiation 2.3 Q Java Server Pages (http://java.sun.com/products/jsp/) Q Answer to Microsoft’s Active Server Pages Q Provide mechanism for including tags/scriptlets into an HTML or XML page Q JSPs have .jsp extension and are processed using a special servlet Q JSP page is compiled into a servlet upon first access or after each modification 12 Q Ability to instantiate and access JavaBeans within JSP pages 4 MVC or Model 2 Design Pattern Q Used to implement Modern Web Applications as a combination of Q Servlets/Servlet filters Q Controller receiving/filtering requests from the user Q Updates the application’s model composed of JavaBeans Q Passes the page request to a view JSP Q Java Server Pages Q Display information based on the current state of the application’s model Q JavaBeans Q Enable component reuse Q Custom Tag Libraries Q Make it possible to move source code out of the JSP where it is difficult to maintain and into reusable JavaBeans Q Rich array of Java APIs Q See http://www.mhsoftware.com/resources/iisjserv.html for a comparison of IIS/ASP and Servlet/JSP technology 13 Servlets and JSPs Examples Q JSP displaying a banner image based on who is referring the user to the site: <%@ page import="com.ibm.jspredbook.*;” errorPage="error.jsp" %> <body bgcolor="#FFFFFF"> <!--the referer header is used to trap the url the user is coming from --> <IMG SRC="/servlets/ImgServlet?from=<%=request.getHeader("Ref erer")%>"> </body> </html> 14 Servlets and JSPs Examples (continued) Q Servlet referenced in the IMG tag of the previous slide (partial): package com.ibm.projsp; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import java.io.*; public class ImageServlet extends HttpServlet { private String docHome = "."; public void service( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); ServletConfig config = getServletConfig(); ServletContext application = config.getServletContext(); File file = findFile(request, response); if (file == null) { return; } else { response.setContentType(application.getMimeType(file.getName())); response.setContentLength((int) file.length()); sendFile(file, response); } 15 } 5 Architectural Considerations Q Page-Centric v.s. Dispatcher Type Q Page-Centric architectures have a JSP handling the request directly Q Dispatcher architectures include a Servlet that handles the request and delegates to a JSP Q Sample architectural patterns: Q Page-View (Page-Centric) Q Page-View with Bean (Page-Centric) Q Mediator-View (Dispatcher) Q Mediator-Composite View (Dispatcher) Q Service-to-Workers (Dispatcher) 16 Part III eXtensible Server Pages (XSP) Environment Also See Session 3 Handout on: “Cocoon Streamlined Installation Instructions” 17 Cocoon 2 Q Web Publishing framework implemented as a servlet Q Requires a servlet engine to operate Q Cocoon 2 has been rearchitected to truly support the MVC pattern Q Cocoon processor: Q Cocoon Java type that takes a DOM tree as an input and produces another Q Cocoon producer: Q Cocoon Java type used to feed the initial XML content to the Cocoon processing pipeline Q e.g., Cocoon serves static XML documents using its built-in FileProducer Q Cocoon processing instructions act upon a whole document, which generates a result document Q <?cocoon-process type="xsp"?> Q Result document is passed to the next Cocoon processor Q Similar to servlet chaining 18 Q Alternatives: Rocket, CPan’s, http://xmlsoftware.com/publishing/ 6 Introduction to XSPs Q See: Q Apache Cocoon technology: http://xml.apache.org/cocoon/xsp.html Q XSP / JSP differences: http://www.onjava.com/lpt/a/620 Q Publishing Frameworks: http://www.oreilly.com/catalog/javaxml/chapter/ch09.html#69379 Q XSP: Q Core technology available in Apache Cocoon 2 Q Approach separates content, style, and logic as XML files and uses XSL to merge them Q XSP engine Q Implemented as a Cocoon processor that accepts an XSP as input Q Translates XSP into equivalent source program, compiles, loads and executes it Q XSP generates producers while JSP technology generates servlets Q All XSP roducers are derived from an abstract base class XSPPage 19 Minimal XSP Page Q XML document that has the following characteristics: Q Processing instruction invoking the XSP processor: Q <?cocoon-process type="xsp"?> Q Document root element must be: Q <xsp: page> Q All language and Taglib declarations must appear as attributes in the root element tag: Q e.g., <xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core”> Q Optional elements: Q <xsp:logic> (procedural logic embedding) and <xsp:expr> (program expression inlining) Q Optional processing of the resulting page via a style sheet for viewing purpose Q <?cocoon-process type="xslt"?> <?xml-stylesheet href="sample.xsl" type="text/xsl"?> 20 Q Note: Minimal JSP page is an HTML document XSP Example Q XSP logic tag: . <p> Good <xsp:logic> String timeOfDay = ( new SimpleDateFormat("aa") ).format(new Date()); if (timeOfDay.equals("AM")) { <xsp:content>Morning</xsp:content> } else { <xsp:content>Afternoon</xsp:content> } </xsp:logic>! </p> . Q May be rephrased using a library tag as: ... <p>Good <util:time-of-day/>!</p> 21 ... 7 XSP v.s. JSP Q XSP Q Tailored to maximize code reuse Q Allows separation of content from presentation Q Developers handle content generation (content can static or generated via servlets or Java code) Q XML/XSL authors handle style/presentation via style sheet modifications Q As XSP processing occurs prior to styling, the content can be presented in various ways Q Keep development teams well isolated Q Can use IBM's Bean Scripting Framework (BSF) to support other scripting languages in addition to Java Q JSP Q Popular and widely understood Q Requires tight collaboration between application developers and presentation designers 22 Q At best presentation designers must understand how to use tag libraries Part IV Conclusion 23 Summary Q Microsoft IIS with COM+ and ASP is a Page-Based Script- oriented application server Q COM+ and ASP are “equivalent” to J2EE EJB and JSP Q Servlets are more efficient than traditional CGI approaches, and are not subject to the issues that arise from in-process approaches (ISAPI, NSAPI, fast-CGI, etc.) Q JSPs allow custom tags and Java scriptlets within HTML pages Q JSPs are a first step towards separation of content/presentation.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages10 Page
-
File Size-