© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, 2006 201 Developing Java Web Applications with WTP Arthur Ryman IBM Rational.

Презентация:



Advertisements
Похожие презентации
© 2006 IBM Corporation Made available under the EPL v WebSphere Services Technical Conference world class skill building and technical enablement.
Advertisements

© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
IBM Rational Software Development Conference 2006 OC02 © 2006 IBM Corporation ® The Eclipse Web Tools Platform Project: Supporting Open Standards with.
© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Quick Tour of WTP Arthur Ryman IBM Rational Software.
© 2009 Avaya Inc. All rights reserved.1 Chapter Two, Voic Pro Components Module Two – Actions, Variables & Conditions.
Using Dreamweaver MX Slide 1 Window menu Manage Sites… Window menu Manage Sites… 2 2 Open Dreamweaver 1 1 Set up a website folder (1). Click New…
Java Server Pages(JSP). JavaServer Pages (JSP) позволяют вам отделить динамическую часть ваших страниц от статического HTML. Вы, как обычно, пишете обычный.
© 2006 by IBM and Oracle; made available under the EPL v1.0 | Santa Clara | Mar. 23, 2006 Arthur Ryman, WTP PMC, IBM Rational Software Raghu Srinivasan,
© 2002 IBM Corporation Confidential | Date | Other Information, if necessary © Wind River Systems, released under EPL 1.0. All logos are TM of their respective.
© 2006 by IBM; made available under the EPL v1.0 | March 20, 2006 | Jeffrey Liu Release Lead IBM Rational Managing APIs with Eclipse API Scanner.
© 2006 Cisco Systems, Inc. All rights reserved. SND v Configuring a Cisco IOS Firewall Configuring a Cisco IOS Firewall with the Cisco SDM Wizard.
© 2006 by IBM; made available under the EPL v1.0 | October 11, 2006 | Tour of the Web Tools Platform (WTP) Project David Williams Eclipse WST Project Lead.
© 2006 IBM Corporation Made available under the EPL v WebSphere Services Technical Conference world class skill building and technical enablement.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Managing Your Network Environment Managing Cisco Devices.
Overview of the Paysonnel CE. Overview Paysonnel CE Go to URL- 1 Click [Login to Paysonnel CE] 2 How to Log-in to Paysonnel CE 1 2.
© 2006 Cisco Systems, Inc. All rights reserved. HIPS v Administering Events and Generating Reports Managing Events.
© 2005 Cisco Systems, Inc. All rights reserved. IPTX v Configuring Additional Cisco CallManager Express Features Configuring Cisco CallManager Express.
© 2002, Cisco Systems, Inc. All rights reserved. AWLF 3.0Module 7-1 © 2002, Cisco Systems, Inc. All rights reserved.
© 2005 Cisco Systems, Inc. All rights reserved. IPTX v Configuring Additional Cisco CallManager Express Features Defining TAPI Support for Cisco.
© 2006 Cisco Systems, Inc. All rights reserved.ISCW v Cisco IOS Threat Defense Features Configuring Cisco IOS IPS.
Транксрипт:

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Developing Java Web Applications with WTP Arthur Ryman IBM Rational Software

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Abstract The Eclipse Web Tools Platform (WTP) project provides a set of tools for developing standards-based multi-tier Java Web applications. This session focuses on the tools available for developing the presentation tier. In WTP 1.5, these tools include editors, wizards, and validators for creating HTML, CSS, JavaScript, XML, XML Schema, servlets, and JSP. The use of these tools will be illustrated through the development of a simple Java Web application. The session concludes with a discussion of the recently added JSF and AJAX subprojects. This is an intermediate level session aimed at developers and managers who are creating Web applications. Some prior experience with WTP is helpful. After this session you will have a good understanding of how WTP can be used to develop the presentation tier of Java Web applications.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, WTP support for presentation tier development Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Presentation Tier Presentation Tier separates the user interface of a system from its core. Constructing the presentation-tier HTTP, HTML, CSS, JavaScript TM, XML, XSLT, servlets, JSP, and JSF Client & Presentation Tier Persistence-Tier Business-Tier

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Interaction Design Viewing the application through the eyes of the intended users League Planet Personas: The Inmates are Running the Asylum [ Alan Cooper 2004] Sheila MacPherson Manager Anne French Fan Peter Alverez Adminstrator Kenny Pau Player public domain clipart from openclipart.org

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Graphic Design Creative work Page layouts and the selection of colors, typography, and images Graphic elements, content and presentation logic Style sheets make designs manageable CSS - control display properties of HTML tags (color, font, space,..) XSLT - general rearrangements and transformations of XML content Reading Web Pages That Suck [Flanders1996] The Non-Designer's Design Book [Williams1994]

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Structure of the Presentation Tier J2EE TM Multi Tier Distributed Application client tier - the end-user device middle tier -Web and EJB containers Enterprise Information System (EIS) tier – databases and other business systems Presentation Tier Persistence-Tier Business-Tier Client Tier Middle Tier (Server Runtime Environments) Web Modules EJB Modules Enterprise Information Systems (EIS)

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, WTP support for presentation tier development Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New Projects Static Web project is simply a collection of HTML, CSS, JavaScript, etc. resources can be sent directly to Web browsers no J2EE server-side processing. Launch Eclipse, and invoke the File->New->Project

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Static Web Project Click the Next button to open the New Static Web Project wizard

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Static Web Project Facets facet specifies what you want to develop in a project Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Web Content Folder contains the resources that get published to the Web server

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Static Web Project in J2EE Perspective Project Explorer

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML Add HTML pages to the project WTP currently only supports HTML source editing HTML and XHTML Reading: The HTML Sourcebook: A Complete Guide to HTML [Graham1995]

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML File Associations Window > Preferences > General Editors File Associations

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New HTML Page Right click on the WebContent folder and select the New HTML Enter name

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML Templates WTP provides a few built-in templates accept the default selection of HTML 4.01

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML Editor Wizard creates a new HTML file and opens it in HTML source editor

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Content Asist in HTML editor Enter HTML Ctrl + Space for assist Rosehill Girls Hockey League Regular Season Schedule Rosehill Girls Hockey League Regular Season Schedule Date Time Arena Visitor Home Score Jan. 7, :00 PM Hillview High School..

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Web Browser WTP provides built-in Web browser right click and invoke the Open With Web Browser

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Web Browser Preferences Open General-Web Browser Preference page

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Structured Source Editor WTP has source extendable editors for many of the formats HTML, CSS, JavaScript, XML, DTD, XSD, WSDL, JSP J2EE deployment descriptors including web.xml, ejb-jar.xml, and application.xml Major features: Undo and Redo Syntax Highlighting Formatting Content Assist Error Highlighting Marginal Indicators Templates and Snippets

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Structured Text Editor Preferences General->Editors->Structured Text Editors Web and XML preferences Text Editors

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Templates A template is a text pattern that acts as a boilerplate for a document or some part of a document. A template contains a combination of static text and variables Variable syntax ${name} – date, user Most WTP editors support templates Template Preferences for HTML 1. Open the Preferences dialog 2. Select the HTML templates page 3. Click the New button to add the new template.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Template Preferences

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML tag template Click the New button to add the new template. Try in the HTML editor Ctrl+space ${cursor} 1 2 3

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Snippets Text patterns that consist of static text and variables Like templates have their own view which presents them as a palette of drawers Use Snippets view instead of using content assist select the element we just inserted as a template right click, and invoke the Add to Snippets Choose category 1 2

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, CSS Editor Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, CSS CSS let's you specify styles for elements A stylesheet contains a list of style rules a rule consists of a selector and a set of properties Selector an element name, a path of element names, a class, or an id Property name and a value value Reading: Cascading Style Sheets, level 2, CSS2 Specification [CSS2]

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, HTML page that uses CSS Link to css file and set tag classes Save a copy of your modified html Rosehill Girls Hockey League Regular Season Schedule Jan. 7, 2006

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New CSS File Using the New File wizard, create a new CSS file named schedule.css in the WebContent

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, CSS Editor CSS editor opens schedule.css Try content assist Save the file body { font-family: sans-serif; } h1 { background: blue; color: white; } h2 { color: blue; } thead { background: red; } td { padding: 4pt; }.odd-row { background: rgb(200, 200, 200); }.even-row { background: white; }

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Try schedule-css.html open schedule-css.html in a Web browser

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Java Script Editor Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, JavaScript Client tier processing by using JavaScript in the Web browser requires much more space than is available here to do it justice Update schedule page by adding an link that is obfuscated to avoid spam Save a copy of the schedule-css.html as schedule-js.html Will use this file as our playground Reading: JavaScript: The Definitive Guide, Fourth Edition [Flannagan2002]

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, schedule-js.html Open in HTML editor Has support for JavaScript Try the content assist Add this at the end:.... var protocol = "mailto"; var user = "webmaster"; var server = "leagueplanet.com"; function contact() { window.open(protocol + ":" + user + + server, "_self"); } For questions about this Web page, please contact webmaster at leagueplanet dot com

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Try schedule-js.html open schedule-js.html in a Web browser Click the link 1 2

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Client-side form validation with JavaScript Try building a form validator with JavaScript Create a JavaScript file (.js extension) for your code

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, XML and XSLT Transformation Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, XML and XSLT XML is the standard for data interchange on the Web Structured data Define your own vocabulary XSLT helps us separate the content from presentation CSS encapsulates style of a documents Transform XML data to to HTML or other types of text Describe schedule as XML Use XSLT and CSS to transform it Reading: XML: A Primer [StLaurent1998b] XSLT Reference [Nic2000] w3c.org

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a new XML document XML document for schedule Right click the WebContent folder and select the New->Other New XML File from scratch (schedule.xml) 1 23

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, XML Editor Wizard opens an XML editor Validate your XML Project Explorer view, right click, and select the Validate XML Rosehill Girls Hockey League Regular Season Jan. 7, :00 PM Hillview High School Ladybugs Vixens Note the reference to the schedule.xsl that we have not yet created

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, XML Editor Design Tab Click Design tab XML-Expand All menu item to view the file as a form

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a new XSLT document XSLT is an XML document Use New->File schedule.xsl WTP recognizes the *.xsl and associates with XML editor No XSL validation yet

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, schedule.xsl Use the XML editor

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Try XSL transformation Major browsers can transform xml using XSLT Open schedule.xml in a browser Open the File Associations Preference page, Associate *.xml with Web browser

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, XML in Web Browser

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, DTD Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Correct XML documents Well-formed obeys general XML syntax rules Valid Correct according to a grammar XML Grammar DTD (SGML specification) XSD (XML grammar) WTP supports both develop a DTD to check the correctness of the League Planet game schedule.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New DTD File To perform true validation, you need to create a DTD Select the WebContent folder, right click and select the New >Other XML > DTD Name schedule.dtd

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Schedule DTD Wizard opens schedule.dtd in DTD editor Syntax highlighting

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Associate XML with a DTD Use XML Editor to open schedule.xml

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Validation with a DTD Valid schedule XML Introduce an error XML file highlites errors Problems views lists

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Projects - Servlets Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Middle Tier Presentation Logic in the middle tier Dynamic Web Projects for J2EE Web module Requires a server runtime environment 1. Add Apache Tomcat to your workspace, 2. Create a dynamic Web project that uses Tomcat, and 3. Develop a servlet that dynamically generates HTML using server-side XSLT.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Servers Web application servers Extended Web servers Capable of hosting Web applications WTP extends Eclipse with server runtime environments Run/Debug on Server Support Tomcat, JOnAS, Geronimo, JBoss, WebSphere®, WebLogic,.... Using a server with WTP is a three-step process: 1. Obtain and install the server runtime environment. 2. Add the server runtime environment to your workspace. 3. Create a server configuration, and add dynamic Web projects to it.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Adding Tomcat to Workspace Obtain and Install Tomcat Open the Preferences dialog and select the Server page

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Installed Runtimes Click Add...

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New Server Runtime New server runtime wizard opens Choose Tomcat from Apache category

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Tomcat Server Click next to go to the Tomcat Wizard Enter location and choose a JDK Click Finish 1 2

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Projects Dynamic Web projects to host the development of J2EE modules Combine Java and Web Development Support Servers Create a Web module for League Planet ice hockey schedules: Choose New->Dynamic Web Project Enter name Select Tomcat

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Project Facets Project facet describes runtime aspects of the Web module Choose defaults Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Web Module Set context root Directories for its Web and Java resources

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Project - IceHockeyWeb Click Finish. WTP creates the project and populates it with configuration files such as the J2EE Web deployment descriptor, web.xml

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Servlets In this iteration, you will develop a servlet that applies XSLT on the server using the Transformation API for XML (TrAX) which is part of JSR 63: The Java API for XML Processing (JAXP) [JSR63] Prepare: Copy schedule.xml, schedule.xsl, and schedule.css to WebContent

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New Servlet IceHockeyWeb project, right click, and select the New->Servlet Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create Servlet Ensure IceHockeyWeb is selected as the Project \IceHockeyWeb\src is selected as the source folder Enter org.leagueplanet as the Java package ScheduleServlet as the Class name. The Superclass javax.servlet.http.HttpServlet Click the Next button.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, URL Mappings Specify information that goes in web.xml Accept the default Name Enter a brief Description. Add /schedule as URL mapping Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Servlet Stub Methods methods that you want to handle in your servlet and will create stubs to handle http requests Select doGet Click Finish

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, ScheduleServlet Wizard creates the Servlet and deployment descriptor and opens the Servlet in Java editor

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Transforming XML with XSLT using TrAX Change the doGet as follows: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { ServletContext context = getServletContext(); InputStream xsl = context.getResourceAsStream("schedule.xsl"); Source xslSource = new StreamSource(xsl); TransformerFactory factory = TransformerFactory.newInstance(); Templates templates = factory.newTemplates(xslSource); Transformer transformer = templates.newTransformer(); InputStream xml = context.getResourceAsStream("schedule.xml"); Source xmlSource = new StreamSource(xml); PrintWriter out = response.getWriter(); Result htmlResult = new StreamResult(out); transformer.transform(xmlSource, htmlResult); response.flushBuffer(); out.flush(); } catch (TransformerException e) { throw new ServletException(e); }

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run on Server – Create Server Configuration ScheduleServlet.java, right click select the Run AS -> Run on Server The Run on Server wizard opens: Select Tomcat Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add Web Module to Server Configuration is a list of Dynamic Web projects that will be deployed to the server Add and Remove Projects: Add IceHockeyWeb Click Finish

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run on Server – ScheduleServlet.java Wizard creates the Server, starts it, publishes the IceHockeyWeb project to it, and launches the Web browser using the URL mapping for the servlet

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Server Project Wizard created a special new project named Servers to hold the Server configuration Tomcat v5.0 localhost-config

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Servers View Server is also displayed in the Servers view lets you start, stop, and restart

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Projects - JSPs Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, JSP JSP is the J2EE recommended way to dynamically generate Web pages. You will normally use JSP to generate HTML Hybrid file that combines Java and a script such as XML or HTML The server tranlates JSP into a Java servlet WTP has JSP Creation Wizard JSP editor JSP debugging (JSR 45) Run on Server In this iteration you'll develop JSPs that allow League Planet users to log in and out of the Web site.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a User Class New->Class create a Java class named User public class User { private boolean loggedIn = false; private String userId = ""; public boolean isLoggedIn() { return loggedIn; } public void setLoggedIn(boolean loggedIn) { this.loggedIn = loggedIn; } public void logIn(String userId) { setLoggedIn(true); setUserId(userId); } public void logOut() { setLoggedIn(false); setUserId(""); }

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a New Servlet Login Servlet URL /login private void forward(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = getUser(request); String url = user.isLoggedIn() ? "/logout.jsp" : "/login.jsp"; ServletContext context = getServletContext(); RequestDispatcher dispatcher = context.getRequestDispatcher(url); dispatcher.forward(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { forward(request, response); }

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, LoginServlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,.. { User user = getUser(request); String userId = request.getParameter("userId"); if (userId == null) userId = ""; request.setAttribute("userId", userId); String password = request.getParameter("password"); if (password == null) password = ""; String action = request.getParameter("action"); if (action == null) action = "Login"; if (action.equals("Logout")) { user.logOut(); } else { if (userId.length() < 2) { request.setAttribute("userIdMessage", "User id must have at least 2 characters!"); } else { if (!password.equals("guest")) { request.setAttribute("passwordMessage", "Wrong password! Try using: guest"); } else { user.logIn(userId); } } } forward(request, response); }

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New JSP WebContent folder, right click, and select the New->JSP Name it login.jsp Click Next

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Select JSP template JSP markup syntax and that generate HTML or XHTML pages, or the newer XML-compliant syntax for use with XHTML Select HTML Click Finish

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Login.jsp Wizard creates and opens login.jsp in JSP editor Edit the file League Planet Login

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Login.jsp League Planet Login User id: "> Password:

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a second JSP – logout.jsp League Planet Logout League Planet Logout User id:

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run On Server In the Project Explorer, select the LoginServlet Run As->Run on Server Enter User id: anne Password: guest Click Login

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, League Planet Logout We will be forwarded to the logout page

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dynamic Web Projects – TCP/IP Monitor Iteration 1 HTML editor, content assist, templates, and snippets Iteration 2 CSS editor Iteration 3 JavaScript editor Iteration 4 XML editor and XSLT transformation Iteration 5 DTD editor Iteration 6 Dynamic Web Projects - creating a servlet Iteration 7 JSPs Iteration 8 TCP/IP Monitor, http traffic and sessions

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, TCP/IP Monitor WTP contains a very useful tool called the TCP/IP Monitor that lets you peek into the HTTP traffic and see what's going on. In this iteration, you'll monitor the HTTP traffic for the LoginServlet to ensure that session tracking is working correctly.

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Monitoring Ports Servers view, select the Tomcat server, right click Monitoring->Properties

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add a TCP/IP monitor to Tomcat. Click Add Monitor HTTP Port 8080 Add monitor to port 8081 Click start 1 2

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, The TCP/IP Monitor view Send a request from a new Web browser session Use URL: Notice the cookie

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Presentation Tier Summary We have discussed the structure of the presentation tier WTP tools for developing the client and server portions Familiarized ourselves with HTML, CSS, JavaScript, XML, DTD, JSP, XSL, Servlets Servers TCP/IP Monitors

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, 2006 EclipseWorld 2006 WTP Track and Subprojects

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, The JSF Tools Project Technology Preview release with WTP 1.5 Features Full-fledged Faces Config Editor Enhanced JSF-JSP Source Editor JSF Library Registry Extensible framework Download / / Release 1.0-WTP2.0 Features Visual JSF Page Designer JSF 1.2 support First release of APIs Requirements

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, AJAX Toolkit Framework Provides tools for developing AJAX/DHTML applications JavaScript Debugger Embedded Mozilla Browser DOM Inspector / JavaScript Console JavaScript Validation Extensible framework for adding AJAX runtimes to eclipse AJAX Personality Builder New Enhancements New CSS Tools and Improved DOM Inspector Configuring and Deploying to a HTTP Server JavaScript Debugging Enhancements Debugging using a HTTP/File URL. Expression Support Project in Incubation Phase (

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dali JPA Tools Project Tools and frameworks for building applications with the Java Persistence API (JPA) part of Java EE 5. Support for both EE and SE development O-R Mapping validation with intelligent code assist for both Java and Database values. Quick start generation wizards Entities from Tables Tables from Entities Salvador Dalí. The Persistence of Memory © 2005 Salvador Dalí, Gala-Salvador Dalí Foundation/Artists Rights Society (ARS), New YorkThe Persistence of Memory

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, WTP Track Wednesday, September 6 All Day T-4 Develop Better J2EE Applications With the Web Tools Platform – JuddT-4 Thursday, September 7 8:30 AM 101 Quick Tour of the Eclipse Web Tools Platform – Ryman101 8:30 AM 107 Leveraging JSF Components – Katz107 10:30 AM 201 How to Build Java Web Applications With the Web Tools Platform – Ryman201 1:15 PM 301 Facing JavaServer Faces Development With JSF Tools – Jacobi301 3:15 PM 401 Consuming and Producing Web Services With Web Tools – Judd401 Friday, September 8 8:45 AM 501 Developing Java Web Services With the Web Tools Platform – Ryman501 10:45 AM 601 Extending the Web Tools Platform With Ant and PDE – Shittu601 1:45 PM701 Building Applications With the Java Persistence API and Dali – S. Smith701 3:45 PM 801 How to Use and Extend Eclipses XML and Schema Tools – Williams, Salter, Dahyabhai801

© 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Attributions WebSphere is a registered trademark of International Business Machines Corp. in the United States, other countries, or both. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.