Скачать презентацию
Идет загрузка презентации. Пожалуйста, подождите
Презентация была опубликована 10 лет назад пользователемПотап Лешаков
1 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Quick Tour of WTP Arthur Ryman IBM Rational Software
2 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7,
3 3 Abstract The Eclipse Web Tools Platform (WTP) project provides a set of tools for developing standards-based multi-tier Java TM Web applications. The project contains tools for HTML, CSS, JavaScript, XML, XML Schema, Web Services, servlets, JSP, EJB, and Data access. This session gives an overview of WTP 1.5, which is part of the Eclipse 3.2 simultaneous release, and demonstrates its main areas in a Quick Tour. The Quick Tour shows how to configure an application server, create a Web project, add and debug a JSP, perform database access, and develop a Web service. This is an introductory level session aimed at developers and managers who are creating Web applications. No prior experience with WTP is required. After this session you will have a good understanding of the main functional components of WTP and how it can be used to develop Java Web applications.
4 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Objectives You will learn about the structure of the Eclipse Web Tools Platform (WTP) project You will be given an overview the WTP release roadmap You will be shown a Quick Tour demonstration that touches on many of the key functional components of WTP After this session you will be able to use WTP and attend further sessions that go into more detail about J2EE and Web services tools 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.
5 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Outline Project Overview Release Roadmap New in WTP 1.0 New in WTP 1.5 Beyond Callisto Quick Tour Demo Dynamic Web Projects JSPs and Servlet Database Access Web Services
6 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Project Overview WTP provides tools for Java Web application development Tools for application developers Platform for tool developers Subprojects focus on open standards Web Standard Tools – IETF, W3C, OASIS, WS-I, ANSI, etc J2EE Standard Tools – JCP IBM contributed core components of Rational® Application Developer V6.0 and remains the largest contributor BEA, Oracle, Sybase and many others participate in WTP development IBM has adopted WTP in WebSphere Application Server Toolkit V6.1 IBM will adopt WTP in a future version of Rational Application Developer
7 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, IETF W3C OASIS WS-I ECMA ANSI De Jure Standards De Facto Standards Web Technologies Java Technologies WST HTML, XML, XSLT, CSS, JS, WSDL, SOAP, UDDI JST Servlet, JSP, EJB, JAX-RPC, JDBC, JAXP, JSF, J2EE XUL PHP Struts Hibernate Spring JDO WTP Subprojects and Open Standards SQL JCP Apache ObjectWeb SourceForge Mozilla Zend
8 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Web Standard Tools (WST) Web Projects Web server control Structured Source Editing Framework HTML, JavaScript, CSS XML, DTD, XSD Web services (WSDL, WS-I) SQL, relational database access
9 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, J2EE Standard Tools (JST) J2EE Projects J2EE server control Servlets JSP EJB Java Web services (JAX-RPC)
10 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Release Roadmap WTP 0.7, July 2005 – Tools for Application Developers September, 2005 WTP 1.0, December 2005 – Platform for Tool Developers February, April, July 2006 WTP 1.5, June 2006 – Callisto Simultaneous Release September Q 2007 WTP 2.0, June 2007 – Web 2.0, Java EE 5
11 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New in WTP 1.0 First wave of Platform APIs Component descriptors/scanners Initial Feature definitions Project Facets External server adapters and runtimes installed via Update Manager More supported servers Adopter Hot List Improved Help Improved Scalability Lots of other bug fixes and enhancements!
12 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, New in WTP 1.5 (Callisto) Initial steps towards Java EE 5 JSF Tools Incubator Dali EJB 3.0 Persistence Tools Glassfish server adapter hosted at java.net Components moved to Eclipse Platform: Common Navigator (Project Explorer) Tabbed Property View More Platform APIs Adopter Usage/Breakage Scans XML based Help – DITA Lots of other bug fixes and enhancements!
13 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, JSF Tools Incubator Project Led by Oracle with contributions from Sybase and IBM JSF-JSP page source editor application configuration (faces-config.xml) source/graphical editor JSF library registry
14 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Dali EJB ORM Incubator Project Support for development of Java Persistence API (JPA) persistent Entities within Eclipse Leverage and integrate into existing Eclipse platform and projects, esp. WTP, DTP
15 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Design Time Mapping Validation ADDRESS IDCITYCOUNTRY P_CODE Default mapping wont work!
16 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, WTP Beyond Callisto DTP Adoption Remove Data Tools Java EE 5 support Update J2EE models and API Graduation of JSF and Dali projects AJAX Tools Framework Incubator Improved JavaScript editor and new debugger Collaboration with PHP Tools Project Improved Apache Web server support Collaboration with SOA Tools Project Improved WS-* support Continued definition of Platform APIs and Features Focus on adopters
17 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, WTP Quick Tour Agenda WTP contains a lot of tools – lets start with an overview Iteration 1 configure an application server, create a Web application, develop a simple JavaServer TM Pages (JSP) document that prints a greeting, and run it on the server. Iteration 2 add a login JSP, write Java scriptlets to display the user name, create a Java servlet that controls the application page flow, and debug the servlet and JSPs. Iteration 3 create a database to store user information, develop an SQL query to access it, and add Java Database Connectivity (JDBC) calls to your servlet to invoke the query and retrieve the user information. Iteration 4 deploy the database query as a Web service, generate a JSP test client that invokes the Web service, and monitor the Simple Object Access Protocol (SOAP) message traffic.
18 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 1: J2EE Web Applications In iteration 1 we will configure our development environment, and create a static Web application Tasks: Configure an application server Create a Web application project Develop a simple JavaServer Pages (JSP) document that prints a greeting Run the JSP on the server
19 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Configure an Application Server 1.Window->Preference->Server preferences->Installed Runtimes 2. Click Add. Specify the location of Tomcat. You must specify a JDK so your JSPs will compile. An application server is needed to run our Java Web application
20 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a Web Application Project 1. Select File->New->Project…->Web ->Dynamic Web Project wizard. 2. Name the project Project1. 3. Associate Tomcat with Project1. 4. Click Finish. The project will contain all of our Web artifacts such as JSPs, servlets
21 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Develop a Simple JSP that Prints a Greeting 1. Right click on Project1s WebContent folder and select New->JSP. 2. Name the JSP hello-world.jsp. 3. Click Next. Select JSP with html markup. 4. Click Finish. 5. Change the title and add body contents for Hello, world. The JSP will display Hello, World in a clients Web browser
22 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run the JSP on the Server 1. Right click on hello-world.jsp and select Run As->Run on Server. 2. Tomcat starts up and displays the JSP. To make use of the JSP it must be run on a server, in our case Tomcat
23 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 1 Summary We configured Tomcat to act as our application server We created a Web application project We developed a simple JSP that prints Hello, world in a browser We ran the JSP on the Tomcat server
24 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 2: Servlets and Scriptlets In iteration 1 we created a static Web application In iteration 2 we will create a dynamic Web application Tasks: Add a Java Scriptlet to a JSP Debug a JSP Create a Servlet Debug a Servlet
25 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add a Java Scriptlet to a JSP 1. Add the following scriptlet to the JSPs body: Welcome to WTP, ! 2. Select Run As->Run on Server 3. Provide the name by appending ?user=EclipseWorld Scriptlets allow us to add Java code to a JSP that will get executed on the server
26 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Debug a JSP 1. Set a break point on the line String user = request.getParameter("user"); by double clicking in the margin. 2. Right click on hello-world.jsp and select Debug As->Debug on Server. Tomcat will now restart in debug mode. 3. Select to resume execution. 4. Change the user to Alice. Notice the variables view shows the changed value. Debugging a JSP allows us to step through the JSPs execution path Debug on Server. Tomcat will now restart in debug mode. 3. Select to resume execution. 4. Change the user to Alice. Notice the variables view shows the changed value. Debugging a JSP allows us to step through the JSPs execution path">
27 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a Servlet JSPs should only contain presentation logic. Application logic should be performed by servlets. We will now add a login JSP and a servlet to handle the login request.
28 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a Login JSP 1. Create login-user.jsp the same way we created hello-world.jsp. 2. Add the following content to the JSP: The login JSP will submit information to a servlet using a form Login User Login User Enter your user name:
29 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a Servlet 1. Right click on Project1 and select New->Servlet. 2. Specify the package name org.eclipsecon and the name HelloServlet. 3. Click Next. Accept the default name and mapping. 4. Click Finish. The wizard creates the Servlet skeleton. The servlet will take the input from our JSP, perform some logic, and return either the login JSP or the hello world JSP
30 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add Logic to the Servlet 1. Add the following implementation to the doGet method: Because we specified GET in login-user.jsp we will implement doGet() protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url; String user = request.getParameter("user"); if (user == null || user.length() == 0) { url = "/login-user.jsp"; request.setAttribute("error", "User name must not be empty."); } else { url = "/hello-world.jsp"; } ServletContext context = getServletContext(); RequestDispatcher dispatcher = context.getRequestDispatcher(url); dispatcher.forward(request, response); }
31 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run the Updated Application Right click on login-user.jsp and select Run As->Run on Server
32 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Debug a Servlet 1. Set a breakpoint in HelloServlet on the line String user = request.getParameter("user"); by double clicking in the margin. 2. Right click on HelloServlet.java and select Debug As->Debug on Server. 3. Select to resume execution. 4. Try changing the name and watch the execution path. Debugging a servlet is very similar to debugging a Java class Debug on Server. 3. Select to resume execution. 4. Try changing the name and watch the execution path. Debugging a servlet is very similar to debugging a Java class">
33 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 2 Summary We made our JSP dynamic by adding a Java Scriptlet We debugged our JSP on the server We created a login JSP and a servlet to handle login requests We debugged the servlet on the server
34 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 3: Database Access In iteration 2 we created a dynamic Web application In iteration 3 we will add a data layer to our Web application Tasks: Connect to a Database Execute SQL Statements Add Database Access to our Web Application
35 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Show the Database Views 1. Click on Window->Show View->Other… 2. Select the Database Explorer and Data Output views and click OK. WTP provides two views that assist in working with databases. We need to show these views before proceeding.
36 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Connect to a Database 1. Right click in the Database Explorer and select New Connection… 2. Select Derby Enter a convenient location for the database such as C:\Project1db 4. Enter the location of derby.jar. Its located in the plugins dir in org.apache.derby.core. 5. Click Test Connection. 6. If the connection test was successful, click Finish. Before working with a database we must first connect to it.
37 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Execute SQL Statements 1. Open the SQL Scrapbook by clicking the button in the Database Explorer, selecting the Project1db, and enter a name of project1sql.sqlpage. 2. Enter the following statements into the editor. (You can replace a name with your own. 3. Select each statement individually, right click on it and select Run SQL. 4. Results are shown in the Data Output view. We will now populate our database by executing SQL statements. CREATE TABLE WEB1. LOGIN (USERID CHAR(8) NOT NULL, FULLNAME CHAR(20), PRIMARY KEY(USERID)) INSERT INTO WEB1. LOGIN (USERID, FULLNAME) VALUES ('dai','Naci Dai') INSERT INTO WEB1. LOGIN (USERID, FULLNAME) VALUES ('mandel','Lawrence Mandel') INSERT INTO WEB1. LOGIN (USERID, FULLNAME) VALUES ('ryman','Arthur Ryman') SELECT * FROM WEB1. LOGIN ORDER BY FULLNAME SELECT FULLNAME FROM WEB1. LOGIN WHERE USERID = 'ryman'
38 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Disconnect from the Database 1. Right click on the Project1db in the Database Explorer and select Disconnect. Derby only supports a connection to a given database from one process – we need to disconnect before using the database in our Web application
39 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add Database Access to our Web Application We will now update our Web application to retrieve user names from the database we created There are 4 tasks to perform: 1. Add the Derby library to our Web application 2. Create a class that will access the database 3. Update our Servlet to access the user name from the database class 4. Update our hello world JSP to display the user name
40 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Add the Derby Library to our Web Application 1. Copy derby.jar to WEB-INF/lib note: While this method works fine for a single application, if multiple applications need access to a Derby database a shared copy of Derby must be used. Our application needs access to the Derby libraries in order to access a Derby database
41 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Create a Class that will Access the Database 1. Create a new class named Database.java in the same package as HelloServlet.java. The class will contain all the logic to access the database public class Database { public String lookupFullname(String userid) throws SQLException { Connection connection = null; PreparedStatement statement = null; ResultSet resultset = null; String fullname = ""; try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); connection = DriverManager.getConnection("jdbc:derby:C:\\Project1db"); String QUERY = "SELECT FULLNAME FROM WEB1. LOGIN WHERE USERID = ?; statement = connection.prepareStatement(QUERY); statement.setString(1, userid); resultset = statement.executeQuery(); if (resultset.next()) fullname = resultset.getString("FULLNAME").trim(); } catch (Exception e) { e.printStackTrace(); } finally { if (resultset != null) resultset.close(); if (statement != null) statement.close(); if (connection != null) connection.close(); } return fullname; } }
42 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Update Our Servlet to use the Database class 1. Update the doGet method of HelloServlet.java to use Database.java. The Servlet will now access the user name from the database protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url = "/hello-world.jsp"; String user = request.getParameter("user"); if (user == null || user.length() == 0) { url = "/login-user.jsp"; request.setAttribute("error", "User name must not be empty."); } else { try { String fullname = new Database().lookupFullname(user); request.setAttribute("fullname", fullname); } catch (SQLException e) { e.printStackTrace(); } } ServletContext context = getServletContext(); RequestDispatcher dispatcher = context.getRequestDispatcher(url); dispatcher.forward(request, response); }
43 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Update JSP to Display the User Name 1. Update the hello-world.jsp to retrieve the value of the fullname parameter and use it instead of the user parameter if it has been specified by changing the Scriptlet as follows: The JSP needs to be updated to use fullname.
44 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Run the Updated Web Application 1. Run login-user.jsp on the server. 2. Try entering a user id. The resulting page now displays the name instead of the user id.
45 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 3 Summary We connected to a Derby database We executed SQL statements to populate the database and view the values we added We added database access to our Web application enabling the application to display the user name instead of the user id.
46 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 4: Web Services In iteration 3 we created a data layer for our Web application In iteration 4 we will expose that data through a Web service Tasks: Deploy a Web service Test a Web service with a test client Monitor SOAP messages
47 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Deploy a Web Service 1. Right click on Database.java and select Web Services->Create Web service. 2. Check the following items: -Start Web service in Web project -Generate a Proxy -Test the Web service -Monitor the Web service 3. Click Finish. We will create a Web service using the bottom-up approach to expose our Database.java class.
48 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Test a Web Service with a Test Client 1. Click on the lookupFullname method. 2. Enter the name ryman. 3. Click Invoke. 4. The Result pane displays the full name Arthur Ryman associated with the user id ryman. The test client allows you to easily test a Web service. The test client was created by selecting the option in the WS wizard
49 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Monitor SOAP Messages 1. The message you sent when testing the Web service can be seen by opening the TCP/IP monitor view. If not already open select Window->Show View->Other… ->Debug->TCP/IP Monitor 2. Use the test client to test another name. The result shows up in the TCP/IP monitor. Web services send SOAP messages between the client and server We can monitor these messages to see the traffic and find problems
50 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Iteration 4 Summary We deployed a Web service that allows programmatic access to our database We tested the Web service with a test client generated by the Web service wizard We monitored SOAP messages sent to and from the Web service
51 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Quick Tour Summary WTP contains many tools that simplify the development of Web applications including working with databases and working with Web services Some more technologies supported by WTP include: CSS, DTD, EAR, EJB, HTML, XHTML, J2EE, JavaBeans TM, JavaScript TM, JSP, Servlet, SQL, WSDL, XML, XML Schema, WAR, Web services
52 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, 2006 EclipseWorld 2006 WTP Track and Subprojects
53 © 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
54 © 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 (
55 © 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
56 © 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
57 © 2006 by IBM; made available under the EPL v1.0 | Cambridge | September 7, Attributions Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Rational is a trademark or registered trademark of International Business Machines Corp. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
Еще похожие презентации в нашем архиве:
© 2024 MyShared Inc.
All rights reserved.