DBA > Articles

Oracle Workshop's Support for Java EE 5 Web Standards

By: Andrei Cioroianu
To read more DBA articles, visit http://dba.fyicenter.com/article/

For a long time, J2EE seemed a powerful, complex technology. If you took the time to fully understand it, however, you would have discovered ingenious solutions for building scalable component-based multi-tier enterprise applications.

Java EE 5 keeps the power of the old J2EE, but the new version is much simpler and easier to use than the preceding ones. This article explores some of the new Java EE 5 features and walks you though the building of a simple Web application with Oracle Workshop (formerly BEA Workshop). You'll learn how to setup a Web project, build JavaServer Faces (JSF)-based forms, define page-navigation rules, create session EJBs with annotations, use dependency injection in JSF-managed beans, package the application in an EAR file, and deploy it to a local or remote Oracle WebLogic server.

Easier Development with Java EE 5 and Oracle Workshop

In Java EE 5, the JSP and JSF standards are better integrated through the unified expression language, which means any custom JSP tags, including tag files, can now use deferred values and methods in their attributes. Several JSTL tags, such as , support deferred expressions and can be used together with JSF components. In addition, you may safely mix JSF tags and HTML content without explicitly using <f:verbatim> in the Web page as the JSF rendering has been improved to automatically generate those <f:verbatim> components for you.

Java EE's annotations are a good replacement for the XML-based EJB deployment descriptors because you'll have fewer files to edit when making changes. In addition, EJB's persistence is now based on the Plain Old Java Object (POJO) model. Annotations can be used in any Java-based components, including EJBs, Servlets, and JSF managed beans.

The benefits are great. For example, if you need a session bean, you'll just annotate an interface and its implementation. Then, if you want to call it from the Web tier, you can inject a reference to the EJB component into a JSF-managed bean with the @EJB annotation and the application server will take care of the plumbing. The sample application of this article shows how to implement a JSF form, which uses a backing bean to interact with an EJB component that simulates a language-translation service.

Despite these improvements, coding Java EE applications with a text editor is not a wise decision. Fortunately, there are modern Java IDEs that can make developers significantly more productive. Oracle Workshop is an excellent development tool, extending the Eclipse platform with many wizards and editors. It supports the most important Java EE standards, including Servlets 2.5, JSP 2.1, JSF 1.2, JSTL 1.2, EJB 3, JAX-WS, and JAXB 2.0.

One of the Workshop's unique features is the AppXRay technology, which analyzes many types of source files, including Java classes, Web pages, and configuration files. The gathered information is used to improve the development experience though code completion and validation, as well as file-navigation and dependency-visualization via AppXplorer and AppXaminer, which you'll see at work in this article. Web Project Setup

This section shows how to create and configure a Web project. You'll use Workshop's Dynamic Web Project wizard and the Faces Configuration editor for the JSF framework. Creating Web Projects

Click File > New > Project... In the New Project window, expand the Web node and select Dynamic Web Project. Then, click Next.

Workshop will create the Web project containing a WebContent folder where you'll find an index.jsp page that forwards the request to welcome.jsp from the pages sub-folder. You might want to replace <jsp:forward> with <c:redirect> in index.jsp to avoid any problems with the relative URLs in the Web browser.

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:redirect url="/pages/welcome.jsf"/>

The WEB-INF folder contains the configuration files (weblogic.xml, web.xml and faces-config.xml), which can be edited with Workshop. Configuring Web Projects

The web.xml file generated by the New Project wizard already contains the JSF configuration as you can see in the following listing:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" ... version="2.5">

Oracle WebLogic Server 10g Rel 3 supports the new standard XML schemas defined by Java EE 5 for the web.xml and faces-config.xml. Double-click the web.xml file and then right-click the items from the list labeled Deployment Descriptor Elements if you have to make any configuration changes, such as adding new context parameters or servlet/filter mappings.

Double-click weblogic.xml if you want to edit the Weblogic-specific options, which are grouped in six tabs: General, Libraries, Container, JSP, Security and Session. The seventh tab lets you view the source of the configuration file. The following screenshot shows the JSP-related options.

Full article...

Other Related Articles

... to read more DBA articles, visit http://dba.fyicenter.com/article/