270 likes | 387 Views
This unit equips you with the skills to create and manage enterprise applications using WebSphere Studio Application Developer. You will learn to design and test web components, build and deploy servlets, and organize resources efficiently within J2EE applications. Gain expertise in managing project facets, establishing project dependencies, and validating deployment descriptors. Dive into the various perspectives needed for successful application development, including web project creation, servlet management, and XML editing. Enhance your proficiency in building enterprise applications with practical steps to follow.
E N D
Supporting Perspectives for Developing J2EE Applications 4.1.02
Unit objectives After completing this unit, you should be able to: • Create enterprise application projects in WebSphere Studio Application Developer • Use the various Application Developer perspectives involved in developing and testing Web components • Perform the basic steps necessary to build and test a simple servlet
Installed RARs EJB Module JAR file Web Module WAR file Client Module JAR file JSP Pages Servlets HTML, GIFs, etc. EJBs Client Classes J2EE Application -> Modules -> Components J2EE Application EAR file Application DD Web Services DD Web DD Web Services DD EJB DD Client DD
Application Developer Project Mapping • Resources organized in a parallel structure to the J2EE application • Enterprise application project corresponds to the J2EE application itself • Manages the application.xml file • Holds the .war and .jar files which are associated with the application • Projects for each J2EE component • Web projects • EJB projects • Client application projects
Building a Simple Enterprise Application • A developer uses several different perspectives when developing and testing an enterprise application • Example: building a simple servlet • Steps include: • Creating an enterprise application project and associated module projects (Web module for servlet) • Importing and creating module artifacts (create servlets, JSPs, and Web pages) • Adding enterprise application project to a server configuration (run on server) • Launching server in debug mode
Creating an Enterprise Application Project • Launch the New Enterprise Application Project wizard • Designate a name for the project • Choose the Target Runtime that defines the application server type and version
Manage Project Facets • Project facets allow users to add and remove functionality from a project • Select a facet to display a description • Right-click a facet and Show Constraints (the hover box)
Add or Create Additional Modules • Optionally select existing module projects to add to the EAR project, or create new ones
EAR Validator • Application Developer projects can have an associated validator • Invoked on save or explicitly from the context menu • The enterprise application project validator validates the following resources: • Deployment descriptor (application.xml) • All modules contained in the enterprise application • Security roles • EAR roles • EJB roles • EJB references • Resource references
Web Tooling - Web Perspective (1 of 2) • The Web perspective has tools for: • Web project creation • XML, JSP, and HTML file creation, validation, editing • JavaScript editing and validation • Custom JSP tag support (based on JSP 2.0) • web.xml Editor – configuring servlets and JSPs • Servlet creation • WAR file import and export
Web Tooling - Web Perspective (2 of 2) • Additional Web perspective tools: • HTTP and FTP import • FTP export (simple resource copy) to a server • Graphic editing and animation • Cascading Style Sheet (CSS) editing support • Jakarta Taglib availability • Palette View • Struts support • Link viewing, parsing and management • Integration with WebSphere Unit Test Environment • SIP Servlet creation for applications with multimedia conversations • JavaServer Faces and AJAX component layout • Portal Application and Portlets
Web Perspective • View and edit Web components: Servlet, JSP and others
Wizards • A series of wizards assist in creating Web assets Create a Web Page • HTML/XHTML • JSP • JSP Fragment
Specify Project name Configuration EAR Membership Dynamic Web Project Wizard (1 of 3)
Choose project facets Adds functionality to a project Manages project builders Configurations group facets Dynamic Web Project Wizard (2 of 3)
Dynamic Web Project Wizard (3 of 3) • Set the Context root • http://hostname:port/<contextRoot>/<resource> • Content directory • Class files • Deployment descriptor • JSPs • Servlets • HTML • Other support files
Create Servlet Wizard (1 of 3) • Specify Class name and Java package • Select an existing servlet class • To reuse it with different parameters or mappings • Select Annotations • To generate deployment information
Create Servlet Wizard (2 of 3) • URL mappings that will invoke the servlet • http://hostname:port/<contextRoot>/<URLMapping> • Name and description • Parameters in web.xml
Create Servlet Wizard (3 of 3) • Specify class modifiers, interfaces and desired method stubs
Developing Servlets • Edit Java code using the Java Tooling • Can configure servlets within a Web module by editing web.xml file (deployment descriptor)
Page Designer • Design View, Source View, Preview • Content Assist available (Ctrl-Space) Content Assist
Run on Server • To test a Web application, choose an element to invoke via URL • For example, an HTML page, JSP, or servlet) • Select Run As > Run on Server from the context menu
Servers View • Allows creation, configuration and control of servers • WebSphere Application Server 6.1 appears by default • The list of applications deployed to the server appears in a tree
Test Environments and Server Configuration • WebSphere Application Server V7.0 is the default server for • enterprise applications • EJB, and Web projects • The server administrative console is use to configure the server • Projects can be run on different servers types and versions
Checkpoint • What J2EE deployment descriptor configures a servlet? How can you edit this file in Application Developer? • Running an application in a test server is as easy as selecting what menu item?
Checkpoint solutions • The Web Deployment Descriptor resides in the file web.xml. You can locate web.xml, or by double-click on the Deployment Descriptor entry near the top of every Web project in the Project Explorer. • Run As > Run on Server
Unit summary Having completed this unit, you should be able to: • Creating enterprise applications and Web projects in Application Developer • Create a servlet in the Web perspective • Perform the basic steps necessary to build and test a simple servlet