
f538d85efd11a3437c5e84f6ab728005.ppt
- Количество слайдов: 53
Building a J 2 EE Web Application with Eclipse is an open source IDE (Integrated Development Environment) for developing applications in Java, C/C++, HTML, Cobol, Perl, etc. The official Eclipse web site (eclipse. org) says, “Eclipse is a kind of universal tool platform -- an open extensible IDE for anything and nothing in particular. ”
Building a J 2 EE Web Application with Eclipse: • Provides a consistent feature set on most platforms • Supports more than just Java or any single language • Open source and free, yet fully supported • Truly extensible and configurable • Industrial strength
Overview of a Typical Web Application Recall the typical dynamic web application consists of a web browser, web server, html pages, server pages, and a database Eclipse can be used to create the HTML pages, Server Pages, Database Tables, and test it all using a Web Server and a internal web browser. HTML Web browser Scripted page Web server request database
Eclipse support for creating an Testing Web Applications The following components are used: Apache Jakarta Tomcat servlet engine Derby Java. Server Pages Standard Tag Library (JSTL) WTP (Web Tools Project Plugin) HTML Web browser Scripted page Web server request database
Eclipse support for creating an Testing Web Applications The following components will be used: Apache Jakarta Tomcat servlet engine Derby Java. Server Pages Standard Tag Library (JSTL) WTP Java. Server Pages Standard Tag Library (JSTL) HTML Web browser Internet Explorer, Firefox, or internal browser Scripted page Derby database Web server request Apache Jakarta Tomcat servlet engine
Building J 2 EE Web Applications with Eclipse When Eclipse is started, it asks you to choose a workspace. The workspace is the location on the filesystem (folder, directory) where your files will be stored. Afterwards you are presented with the Welcome screen if this is your first time using this workspace.
Building J 2 EE Web Applications with Eclipse On the welcome screen there is an Overview…
Building J 2 EE Web Applications with Eclipse … Tutorials
Building J 2 EE Web Applications with Eclipse … Samples
Building J 2 EE Web Applications with Eclipse And a section on What’s New.
Building J 2 EE Web Applications with Eclipse is divided into Perspectives and Views. A Perspective is the set of screens and functionality for a particular development scenerio (Java, C++). To build a Web Application, first set the perspective to J 2 EE by selecting Window -> Open Perspective -> Other
Building J 2 EE Web Applications with Eclipse Select J 2 EE.
Building a J 2 EE Web Application with Eclipse Next Create a Dynamic Web Project by selecting New -> Dynamic Web Project
Building a J 2 EE Web Application with Eclipse Type in a name for the Project. In this case it is First. Web. Project and press Finish. (May be asked to configure a Server)
Building a J 2 EE Web Application with Eclipse A folder will be created for your Project, appearing under Dynamic Web Projects
Eclipse support for creating an Testing Web Applications The following components will be used: Apache Jakarta Tomcat servlet engine Derby Java. Server Pages Standard Tag Library (JSTL) WTP Java. Server Pages Standard Tag Library (JSTL) HTML Web browser Internet Explorer, Firefox, or internal browser Scripted page Derby database Web server request Apache Jakarta Tomcat servlet engine
DERBY http: //db. apache. org/derby - Relational Database implement in Java - Open source version of IBM Cloudscape - Small footprint - Provides an embedded driver
Using the Derby Database for Persistent Data Adding the Apache Derby Nature to the project makes the class files and tools for Derby available to the Project.
Using the Derby Database for Persistent Data Start the Derby Server by right-clicking on the Project and selecting Apache Derby -> Start Derby Network Server. Select Ok when the dialog box appears.
Using the Derby Database for Persistent Data To create a Database, create a script file and execute it. To create the file, rightmouse click on the project and choose New -> File
Using the Derby Database for Persistent Data Type in the name of an sql script file.
Using the Derby Database for Persistent Data Type the SQL for creating the table and inserting data.
Using the Derby Database for Persistent Data To execute the script, right-mouse click on the script file, choose Apache Derby -> Run SQL Script using ‘ij’
Using the Derby Database for Persistent Data The console shows the results of executing the script file. There is a Database Explorer for further manipulating the database.
Eclipse support for creating an Testing Web Applications The following components will be used: Apache Jakarta Tomcat servlet engine Derby Java. Server Pages Standard Tag Library (JSTL) WTP Java. Server Pages Standard Tag Library (JSTL) HTML Web browser Internet Explorer, Firefox, or internal browser Scripted page Derby database Web server request Apache Jakarta Tomcat servlet engine
UML Class Diagram addaccount main << link >> showaccounts
UML Class Diagram addaccount <<builds>> addaccount. To. DB <<submits>> account. Info confirman. Add
Creating HTML Pages / Server Pages To create a HTML page, right-click on the project and select New -> HTML
Creating HTML Pages / Server Pages Type a filename and press Finish.
Creating HTML Pages / Server Pages Type a filename and press Finish.
Creating HTML Pages / Server Pages Enter HTML for the main menu page.
Creating HTML Pages / Server Pages Enter HTML for the main menu page.
Creating HTML Pages / Server Pages To view the page in a web browser, choose right-mouse click on the editor and choose Run As -> Run on Server. This will start Tomcat (if it is not started) and open the file in the browser. (May have to choose Server and select Projects to add to the Server)
Creating HTML Pages / Server Pages The page displays in Eclipse’s internal Web browser.
Creating HTML Pages / Server Pages To change the web browser Eclipse uses, choose Window -> Preferences -> General -> Web Browser -> Use External browser, and choose the browser you would like used to display the pages (IE, Firefox, etc).
Creating HTML Pages / Server Pages Let’s create the addaccount. html
Creating HTML Pages / Server Pages
Creating HTML Pages / Server Pages
Creating HTML Pages / Server Pages
Creating HTML Pages / Server Pages Here’s what we have so far, viewed with the internal web browser. Selecting the Add Account hyperlink takes us to the addaccount. html page.
Creating HTML Pages / Server Pages Here it is viewed with Internet Explorer.
UML Class Diagram addaccount <<builds>> addaccount. To. DB <<submits>> account. Info confirman. Add
addaccount. To. DB confirman. Add <<builds>> <<submits>> accounts
Eclipse support for creating an Testing Web Applications The following components will be used: Apache Jakarta Tomcat servlet engine Derby Java. Server Pages Standard Tag Library (JSTL) WTP Java. Server Pages Standard Tag Library (JSTL) HTML Web browser Internet Explorer, Firefox, or internal browser Scripted page Derby database Web server request Apache Jakarta Tomcat servlet engine
JSTL (Java. Server. Pages Standard Tag Library) The JSP Standard Tag Library (JSTL) is a collection of custom tag libraries that implement general-purpose functionality common to Web applications, including iteration and conditionalization, data management formatting, manipulation of XML, and database access. • Core Tag Library – looping, expression evaluation, basic input/output • Formatting/Internationalization Tag Library – parsing data, such as dates. • Database Tag Library – tags that can be used to access SQL databases • XML Tag Library – tags can be used to access XML elements
JSTL (Java. Server. Pages Standard Tag Library) Core Tag Library Example <%@ taglib uri="http: //java. sun. com/jstl/core" prefix="c" %> <html> <head> <title>Count to 10 Example (using JSTL)</title> </head> <body> <c: for. Each var="i" begin="1" end="10" step="1"> <c: out value="${i}" /> </c: for. Each> </body> </html>
JSTL (Java. Server. Pages Standard Tag Library) Database Tag Library <%@taglib uri="http: //java. sun. com/jsp/jstl/sql" prefix="sql"%> <sql: query var="cities"> SELECT CITY_NAME, COUNTRY, AIRPORT FROM APP. CITIES ORDER BY CITY_NAME, COUNTRY </sql: query> <c: for. Each var="city" items="${cities. rows}"> <c: out value="${city. airport}” /> <c: out value=“${city_name}” /> <br/> </c: for. Each>
Let’s create the add. Account. To. DB page. Select New -> JSP
Type in a name
Default page
Type JSTL
Here’s what we have when viewed with the internal web browser
. . . And with Internet Explorer
f538d85efd11a3437c5e84f6ab728005.ppt