Web Application Development Using Borland JBuilder 8 WebLogic Edition



Similar documents
Web Application Developer s Guide

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

NetBeans IDE Field Guide

Integrating CaliberRM with Software Configuration Management Tools

CaliberRM / LDAP Integration. CaliberRM

DTS Web Developers Guide

In this chapter, we lay the foundation for all our further discussions. We start

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

Glassfish, JAVA EE, Servlets, JSP, EJB

Application Servers - BEA WebLogic. Installing the Application Server

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Web Container Components Servlet JSP Tag Libraries

JBoss SOAP Web Services User Guide. Version: M5

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

Debugging Java Applications

Install guide for Websphere 7.0

Building and Using Web Services With JDeveloper 11g

Creating Java EE Applications and Servlets with IntelliJ IDEA

For Introduction to Java Programming, 5E By Y. Daniel Liang

Tutorial: Building a Web Application with Struts

Struts Tools Tutorial. Version: M5

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

Advantage Joe. Deployment Guide for WebLogic v8.1 Application Server

JMETER - MONITOR TEST PLAN

Novell Access Manager

Integrated Virtual Debugger for Visual Studio Developer s Guide VMware Workstation 8.0

PowerTier Web Development Tools 4

24x7 Scheduler Multi-platform Edition 5.2

RSM Web Gateway RSM Web Client INSTALLATION AND ADMINISTRATION GUIDE

Working with WebSphere 4.0

Listeners. Formats. Free Form. Formatted

FileMaker Server 14. FileMaker Server Help

The cloud server setup program installs the cloud server application, Apache Tomcat, Java Runtime Environment, and PostgreSQL.

Building Java Servlets with Oracle JDeveloper

Securing SAS Web Applications with SiteMinder

Creating Web Services Applications with IntelliJ IDEA

Java. How to install the Java Runtime Environment (JRE)

NSi Mobile Installation Guide. Version 6.2

Witango Application Server 6. Installation Guide for Windows

Configuring Apache HTTP Server as a Reverse Proxy Server for SAS 9.2 Web Applications Deployed on BEA WebLogic Server 9.2

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

PartnerConnect software. Installation guide

WebSpy Vantage Ultimate 2.2 Web Module Administrators Guide

Team Foundation Server 2010, Visual Studio Ultimate 2010, Team Build 2010, & Lab Management Beta 2 Installation Guide

GP REPORTS VIEWER USER GUIDE

Web-JISIS Reference Manual

USING STUFFIT DELUXE THE STUFFIT START PAGE CREATING ARCHIVES (COMPRESSED FILES)

ServletExec TM 6.0 Installation Guide. for Microsoft Internet Information Server SunONE Web Server Sun Java System Web Server and Apache HTTP Server

Virtual Office Remote Installation Guide

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Using IIS and UltraDev Locally page 1

Crystal Reports Installation Guide

8.7. NET SatisFAXtion Gateway Installation Guide. For NET SatisFAXtion 8.7. Contents

Telephony Toolbar Corporate. User Guide

CONFIGURATION AND APPLICATIONS DEPLOYMENT IN WEBSPHERE 6.1

RoomWizard Synchronization Software Manual Installation Instructions

isupplier PORTAL ACCESS SYSTEM REQUIREMENTS

MICROSOFT BITLOCKER ADMINISTRATION AND MONITORING (MBAM)

2. Follow the installation directions and install the server on ccc

JBoss AS Administration Console User Guide. by Shelly McGowan and Ian Springer

Configuring Devices for Use with Cisco Configuration Professional (CCP) 2.5

Using the DataDirect Connect for JDBC Drivers with the Sun Java System Application Server

TSM for Windows Installation Instructions: Download the latest TSM Client Using the following link:

IBM Rational Web Developer for WebSphere Software Version 6.0

DigitalPersona Privacy Manager Pro

Check current version of Remote Desktop Connection for Mac.. Page 2. Remove Old Version Remote Desktop Connection..Page 8

Configuring Apache HTTP Server as a Reverse Proxy Server for SAS 9.3 Web Applications Deployed on Oracle WebLogic Server

Using Borland Deployment Op-Center to manage CaliberRM, StarTeam, and Mercury TestDirector server environments

WEBAPP PATTERN FOR APACHE TOMCAT - USER GUIDE

Setting up the Oracle Warehouse Builder Project. Topics. Overview. Purpose

Setting Up SSL on IIS6 for MEGA Advisor

VMware/Hyper-V Backup Plug-in User Guide

FileMaker Server 13. FileMaker Server Help

Worry-Free TM Remote Manager

User Guide. Version 3.2. Copyright Snow Software AB. All rights reserved.

Colligo Manager 6.0. Offline Mode - User Guide

RSA Security Analytics

Quadro Configuration Console User's Guide. Table of Contents. Table of Contents

Configuring IBM WebSphere Application Server 7.0 for Web Authentication with SAS 9.3 Web Applications

AssetWise Performance Management. APM Remote Upgrade Guide

Quick Start Guide. Installation and Setup

CA Wily Introscope WebView

Advanced Event Viewer Manual

Budget Developer Install Manual 2.5

Lepide Software. LepideAuditor for File Server [CONFIGURATION GUIDE] This guide informs How to configure settings for first time usage of the software

Installation Guide: Delta Module Manager Launcher

Building Applications with JBuilder

2X ApplicationServer & LoadBalancer Manual

SW5706 Application deployment problems

vtcommander Installing and Starting vtcommander

Contents 1. Introduction 2. Security Considerations 3. Installation 4. Configuration 5. Uninstallation 6. Automated Bulk Enrollment 7.

AN4108 Application note

Bitrix Site Manager ASP.NET. Installation Guide

How To Install An Aneka Cloud On A Windows 7 Computer (For Free)

Application. 1.1 About This Tutorial Tutorial Requirements Provided Files

Rev 7 06-OCT Site Manager Installation Guide

How To Integrate IIS6 and Apache Tomcat

Transcription:

Web Application Development Using Borland JBuilder 8 WebLogic Edition Jumpstart development, deployment, and debugging servlets and JSP A Borland and BEA White Paper By Sudhansu Pati, Systems Engineer March 2003

Contents Introduction... 3 Working with JSPs... 4 Create a project... 4 Attach WebLogic Server to the current project... 5 Attach WebLogic Server to all the projects... 6 Create a Web application... 7 Create a JSP... 9 Make the project... 9 Deploy and run JSP in WebLogic Server... 10 Remote deployment... 13 Debug the JSP... 14 Working with servlets...20 Optimizing Web applications...22 Optimizeit Code Coverage... 22 Optimizeit Profiler... 22 Optimizeit Thread Debugger... 23 Working with Apache Struts...26 What is Struts?... 26 Create a Struts application... 27 Deploy and run the Struts application... 34 Conclusion...35 Troubleshooting...35 Useful links...41 Feedback and suggestions...42 2

Introduction Borland JBuilder, WebLogic Edition is a tightly integrated development solution for building enterprise applications with the market-leading JBuilder development environment on the industry-leading BEA WebLogic Platform. JBuilder WebLogic Edition is a proven solution that makes EJB, Web, XML, and database application development easier with two-way visual designers and rapid deployment on the BEA WebLogic Platform the industry's first unified application infrastructure platform. JBuilder WebLogic Edition enhances developer productivity with support for UML code visualization, refactoring, and unit testing; by providing a unified, simplified, and extensible architecture, BEA WebLogic Platform increases productivity and lowers the cost structure for enterprise IT organizations. This paper provides an overview of creating, testing, and debugging Web applications using JBuilder 8 WebLogic Edition which includes BEA WebLogic Server 7.0. The other platforms and software used to create the exercises are Borland Optimizeit Suite 5, Microsoft Windows XP, and Microsoft Internet Explorer 6.0. JBuilder WebLogic Edition helps to develop, debug, and test Web applications written with JDK 1.4.1, JSP 1.2 and Servlet 2.3 standards. It also supports older versions of JDK, JSP, and servlets. Followings are the list of Web technologies that can be easily developed, debugged, and tested using JBuilder wizards. Web applications developed with other technologies not mentioned here may also be easily imported to JBuilder 8 and managed. 3

Technology Servlets JavaServer Pages (JSP ) InternetBeans Express Apache Struts JavaServer Pages Standard Tag Library (JSTL) Cocoon Applets Description A server-side Java application which can process requests from clients. An extension of servlet technology. JavaServer Pages use custom tag libraries and essentially offers a simplified way to develop servlets. A set of components and a tag library provided by Borland, used for easier presentation and manipulation of data from a database. An open source tag library provided by the Jakarta Project that is used for building Web applications. Struts provides a flexible control layer based on standard technologies like servlets, JSPs, JavaBeans, ResourceBundles, and XML. A tag library provided by Sun that is part of the Java Web Services Development Pack 1.0 (WSDP). It provides a set of tags that allow developers to do common tasks in a standard way. The JSTL consists of four areas, each with its own tag library descriptor (TLD ) and namespace. A servlet-based, Java publishing framework for XML that is integrated into JBuilder. Cocoon allows separation of content, style, and logic and uses XSL transformation to merge them. It can also use logic sheets and Extensible Server Pages (XSP) to deliver dynamic content embedded with program logic written in Java. A specialized kind of Java application that can be downloaded by a client browser and run on the client's machine. Table 1: List of major Web technologies supported by JBuilder WebLogic Edition Working with JSPs Create a project Start JBuilder 8. Click File -> New -> Select Project tab from the Object Gallery. Click Project. Click OK. In the Project Wizard Step 1 of 3 specify a Directory Name and a Project Name. Leave the Template as (Default Project). Hit Finish. 4

For this exercise, the project directory is E:/DEMO/JBWLS and Project Name is TestWeb. Attach WebLogic Server to the current project You can attach the WebLogic Server to the current project. From the JBuilder main menu bar, click Project -> Project Properties. Click Server tab. Select WebLogic Application Server 7.x from the combo box. See Figure 1 for details. Figure 1: Project Properties window allowing users to select application server of choice Note: The Services panel in the left-hand side shows the services provided by the specific server selected in the combo box (in this case, WebLogic Server 7.0). JBuilder is designed to be intuitive and automatically discovers the services provided by a selected Web/application 5

server. Here, all services other than Connector, Deployment, EJB, and JSP/servlet are grayed out because WebLogic Server 7.0 does not provide those services. Note: You can click on each service from the Services panel and see what specific versions of different technologies are supported by the chosen Web/application server. In the above figure, the EJB Service is clicked from the Services panel, and JBuilder is showing the supported EJB versions with WebLogic Application Server 7.x. Note: JBuilder provides users the option of choosing one server for all services in the project or multiple servers providing different servers. With modular services provided by different servers, users can configure different services to be run by different servers. For example, users can select Tomcat for JSP/servlet server, WebLogic Server for EJB, and another server for Connector. For simplicity, select Single server for all services in project. Click Deployment from the Services panel. Note that by default, the Build target for deploying to server is Make. If you prefer not to build the archives at the time of deployment, choose <None> from the combo box. This will stop making the project during deployment and make the deployment faster. Hit OK, and JBuilder project TestWeb is now configured for WebLogic Server 7.0. Attach WebLogic Server to all the projects If you decide to use WebLogic Server 7.x for all of your projects, you can set this as default. From JBuilder menu bar click Project -> Default Project Properties. Click Server tab. Select WebLogic Application Server 7.x from the combo box and choose Single server for all services in the project. 6

Create a Web application JBuilder allows users to create a Web application which can host applets, Web Start launchers, JSPs, servlets, and Apache Struts applications. From the JBuilder main menu bar, click File -> New -> Web tab in Object Gallery -> Web Application. Click OK. See Figure 2 for JBuilder 8 Object Gallery. Figure 2: JBuilder 8 Object Gallery displaying the wizards to create Web applications The Web Application Wizard pops up. Enter Name and Directory entries for the Web application. For this exercise, the Web application name is TestWebApp and directory is TestWebApp. 7

JBuilder provides an option to choose when the developers would like to build a WAR file. For this exercise, select When building project or webapp. From the JBuilder 8 project tree, expand the project and expand the Web application TestWebApp. Expand the deployment descriptors folder. Note that JBuilder has recognized that the target server is WebLogic, so it automatically created the deployment descriptors for WebLogic; web.xml, and weblogic.xml. Click web.xml. This opens the WebApp Deployment Descriptor Editor in the editor pane. See Figure 3 for details. 8

Figure 3: JBuilder 8 Web application Deployment Descriptor Editor Note: The Deployment Descriptor Editor tool in JBuilder provides a graphical user-friendly way to update the web.xml, and it is a two-way tool. It automatically changes the XML source when the Deployment Descriptor Editor is changed. Create a JSP From the JBuilder main menu bar, click File -> New -> Web tab in Object Gallery -> JavaServer Page. Click OK. In JSP Wizard Step 1 of 6, enter a JSP name. For this exercise, the JSP name is TestJSP. Note that the Web application TestWebApp is defaulted for hosting this JSP. You can check both the checkboxes to generate a sample bean and an error page. Click Next. In JSP Wizard Step 2 of 6, you can select InternetBeans technology, different tag libraries from JSTL 1.0, and Struts. Leave the defaults and click Next. In JSP Wizard Step 3 of 6, enter the package name as borland.demo.web. Click Next. At this point, you can click Finish. JBuilder automatically creates a runtime configuration named TestJSP to run the created JSP. Note: A runtime configuration is a setup to run an application in JBuilder 8. Runtime configuration is essential when your project has multiple runnable files/applications and you want to run a specific application. Make the project To make the project, press Ctrl+Shift+F9 or click the Make icon from the JBuilder toolbar. JBuilder may show some warnings because of the use of some deprecated methods. To hide 9

the deprecation and warning messages, click Project -> Project Properties -> Build. Uncheck Show warnings and Show deprecations. As a result of make, JBuilder automatically creates the WAR file for the Web application. The WAR file for this exercise is TestWebApp.war. See Figure 4 for details. Figure 4: JBuilder showing the generated sources, WAR file, and Deployment Descriptors for WebLogic Deploy and run JSP in WebLogic Server When WebLogic Server is started within JBuilder, it automatically deploys the Web application and runs the JSP in the JBuilder AppBrowser. 10

Figure 5 shows running of TestJSP.jsp within JBuilder. Enter any value in the Text Box next to Enter New Value in the AppBrowser, and the value is designed to be displayed next to Value of Bean Property is. Figure 5: WebLogic Server is running within JBuilder and AppBrowser displaying the running JSP Note: JBuilder supports both hot-deployment and auto-deployment with WebLogic. Hot deployment is a feature that allows users to deploy/redeploy archives into Web/application servers and get the contents from the freshly deployed archives without restarting the Web/application server. With auto-deploy, users are not required to create any archives for deployment; they can change the files directly, and the Web/application server automatically activates the changes. 11

By default with JBuilder, the Web application is deployed in exploded format from the project directory (auto-deployment). In this case, the WAR file is not used for deployment. This is the preferred option to work with JSP, since users do not need to redeploy to activate any JSP changes. To turn off this behavior and use WARs or EARs, click Project -> Project Properties. Click the Server tab. Click JSP/servlet service in the Services list. On the right, de-select the option Map project webapps at runtime. If you like to see the deployment status in WebLogic console, start the WebLogic console by clicking Tools -> WebLogic 7.0 Admin Console. Expand mydomain -> Deployments -> Web Applications, and you should be able to see the Web application TestWebApp. See Figure 6 for details. 12

Figure 6: WebLogic 7.0 console displaying the deployed Web application TestWebApp Note: If you do not see WebLogic 7.x Admin Console under JBuilder 8 Tools menu, it is because you have not selected this option during server configuration. Click Tools -> Configure Servers -> Select WebLogic Application Server 7.x from left-hand panel of Configure Servers window, click Custom tab from the right-hand panel, and make sure that checkbox against Add a Admin Console item to the Tools menu is checked. Remote deployment This section explains how to deploy an archive to a remote WebLogic Server. Note: The users need to have a local installation of the application server for the remote deployment because JBuilder needs to use the deployment utilities for that application server. 13

For deploying to a remote WebLogic Server 7.x, from JBuilder menubar click Tools -> Enterprise Deployment. A window called WebLogic 7.x Deploy Settings pops up. Modify the Admin url field to point to the remote server with the remote WebLogic Server host name and port number (http://<servername>:<port number>). See Figure 7 for details. Figure 7: JBuilder remote deployment utility to deploy to remote WebLogic Server Debug the JSP JBuilder supports both local and remote debugging of JSP. 14

Local debugging For local JSP debugging, assign breakpoints in the source code wherever necessary. To assign a breakpoint, simply open the source file and single-click the mouse on that line. Note: For this exercise, the breakpoints are assigned as explained in Table 2. File Line # Breakpoints TestJSP.jsp 8 <jsp:usebean id="testjspbeanid" scope="session" class="borland.demo.web.testjspbean" /> TestJSPBean.java 16 Return sample; TestJSPBean.java 21 sample = newvalue; Table 2: Assigning breakpoints in different files If WebLogic is already running, stop the WebLogic Server. Press Shift+F9 or just click the Debug Project icon. Click TestJSP to start WebLogic in debug mode within JBuilder. See Figure 8 for details. Note: When you click Debug Project, JBuilder starts WebLogic Server in debug mode. Now users can do the debug operations from JBuilder, such as seeing the thread information, breakpoint information, console output, step over, step into, step out, etc. Click the Step Over button until you see the debugger stopping at TestJSPBean.java. 15

Figure 8: JBuilder debugger has stopped at a breakpoint in JSP. The JSP is running in WebLogic JBuilder is designed to recognize all breakpoints and puts a red tick mark against all valid breakpoints and red cross mark against all non-valid breakpoints. Also, JBuilder puts a green arrow against the breakpoints where the debugger stops. Note: JBuilder debugger has an ability to debug across varieties of applications (JSP, servlets, JavaBeans, and Enterprise Java Beans ). Remote debugging Remote debugging is useful when an application is already hosted in a staging area, and it is required to debug the application from a remote machine. 16

Remote debugging in JBuilder is an implementation of Java Platform Debugger Architecture (JPDA). For more information on JPDA, visit http://java.sun.com/products/jpda/ A JPDA transport is a form of inter-process communication used by a debugger application process and the virtual machine that is being debugged (often called the target VM). For more information on transport, visit the following link: http://java.sun.com/products/jpda/doc/conninv.html#transports To test remote debugging for the Web application TestWebApp, you can use your machine as both local machine and remote server. Follow the steps below to remotely debug JSP. Open the project containing the Web application that you wish to debug. Expand the Web application node in the JBuilder project tree. Expand the Deployment Descriptors node (under the Web appnode) and double click weblogic.xml. Change weblogic.xml as shown in Table 3. Weblogic.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 6.1//EN" "http://www.bea.com/servers/wls610/dtd/weblogic-web-jar.dtd"> <weblogic-web-app> <jsp-descriptor> <jsp-param> <param-name>keepgenerated</param-name> <param-value>true</param-value> </jsp-param> <jsp-param> <param-name>debug</param-name> <param-value>true</param-value> 17

</jsp-param> <jsp-param> <param-name>precompile</param-name> <param-value>true</param-value> </jsp-param> <jsp-param> <param-name>compileflags</param-name> <param-value>-g</param-value> </jsp-param> </jsp-descriptor> </weblogic-web-app> Table 3: weblogic.xml for remote debugging of JSP using JBuilder 8 and WebLogic Server 7.x Rebuild project and deploy the Web application as a WAR file (TestWebApp.war ) to WebLogic Server 7.0. To deploy, right-click the Web application node TestWebApp from JBuilder project tree, click Deploy options for TestWebApp.war and click Redeploy. Launch WebLogic Server 7.x in the remote location with debug parameters. To do this, modify startweblogic.bat in your domain directory (example E:\bea\user_projects\mydomain) and add the following parameters to the JAVA_OPTIONS variable -Xdebug -Xnoagent -Djava.compiler=NONE - Xrunjdwp:transport=dt_socket,server=y,address=5555,suspend=n On the local machine where you wish to debug the JSP, open the project in JBuilder. Set the target server to Tomcat 4.0 (or 3.3) 18

On the local machine, under the source path for the project (normally PROJECT_ROOT/src), create a directory named jsp_servlet. If you need to use a source path other than the default, you can get this setting from the project properties dialog (general tab). On the local machine, copy the JSPs you wish to debug to this directory. In this case, copy TestJSP.jsp. On the local machine, open the JSP(s) and set breakpoints where required. On the local machine, click Run Configurations. Click New. Select Type as Application. Click the Debug tab, check the option Enable remote debugging, and select the Attach radio button. Provide a name for this configuration. Let s assume that the configuration name is RemoteDebug. Enter the host name of the remote server in the Host name field, set the Transport type to dt_socket, and set the Address to the value specified in the JAVA_OPTIONS variable in startweblogic.bat file. Set build target to None. Accept all other defaults. Click the Debug button from JBuilder main menu bar and click RemoteDebug. This should open a tab in JBuilder message pane. This process is called attach to the remote server. See Figure 9 for JBuilder message pane showing JBuilder attaching to remote WebLogic Server using socket address 5555. 19

Figure 9: JBuilder 8 attaching to a remote WebLogic Server with transport socket address 5555 Using a browser instance, load your JSP. For this exercise, to load the JSP type the URL http://localhost:7001/testwebapp/testjsp.jsp. The debugger is designed to stop at breakpoints in the JSP. After the debugger stops at a breakpoint, the user can perform the debug operations like step out, step over, etc. Working with servlets JBuilder provides an easy-to-use wizard to create servlets. Let s create a servlet with in the same project TestWeb and Web application TestWebApp. From the JBuilder main menu bar, click File -> New -> Web tab of Object Gallery -> Servlet. Click OK. In Servlet Wizard Step 1 of 5, find package name borland.web.demo from the Package combo box. Also enter the servlet name as TestServlet. This step allows developers to create a Filter servlet or a Listener servlet. Also a Single Thread Model servlet can be created, just by clicking the checkbox against it. For this exercise, lets create a Standard servlet. Click Next. In Servlet Wizard Step 2 of 5, enter the methods that you want to use in the servlet. You can also generate an SHTML file with the servlet. Note: For this exercise, make sure the checkboxes against methods doget() and dopost() are checked and also Generate SHTML file is checked. Click Next. 20

In Servlet Wizard Step 3 of 5, you can enter the servlet name and URL pattern. Leave the defaults and click Next. In Servlet Wizard Step 4 of 5, you can enter the Servlet Request Parameters. Click Next. Servlet Wizard Step 5 of 5 allows you to create a runtime configuration for the servlet. Click the checkbox Create a Runtime Configuration and leave the default configuration name as TestServlet. At this point, the TestJSP runtime configuration is also created, so you can select TestJSP as the Base Configuration. Click Finish. Make the project. To make the project, click Ctrl +F9 or just click the Make icon from the JBuilder toolbar. To deploy and run the servlet, stop WebLogic Server, if it is already running. Click the Run icon from JBuilder toolbar and click TestServlet. Then the AppBrowser automatically runs the servlet with the following URL: http://localhost:7001/testwebapp/testservlet.shtml See figure 10 for details. You are not required to stop WebLogic Server to deploy and run another Web application. If you prefer to run the servlet with your favorite browser, open your browser and type the following URL: http://localhost:7001/servlettest/testservlet.shtml. 21

Figure 10: A servlet is running in WebLogic and displaying the contents in JBuilder AppBrowser Optimizing Web applications JBuilder 8 Enterprises provides integration with Borland Optimizeit Suite. Optimizeit Suite is a separate product. It is available for purchase and a trial download is available from the Borland Web site. Please visit the following link for downloading the latest version of Optimizeit Suite: http://www.borland.com/products/downloads/download_optimizeit.html Optimizeit Suite includes three different tools (Optimizeit Code Coverage, Optimizeit Profiler, and Optimizeit Thread Debugger). For more information, visit: http://www.borland.com/optimizeit/index.html Optimizeit Code Coverage Optimizeit Code Coverage enables developers to view the execution frequency of each class, method, and line of code, and to reduce application footprint by removing dead code. Optimizeit Profiler Optimizeit Profiler enables developers to maximize application speed and reliability and to quickly isolate critical code that requires performance improvements. 22

Optimizeit Thread Debugger Optimizeit Thread Debugger helps developers to solve mysterious thread issues easily, get the status of all threads and monitors in real time, avoid thread starvation and contentions that lead to crashes, and predict deadlocks before they occur. Note: During Optimizeit Suite installation, the installer automatically detects JBuilder installation from the user s machine and prompts the user for integrating with JBuilder. If the user says OK, then both JBuilder and Optimizeit Suite are configured for tight integration. Optimizeit Suite reads the JVMs and helps the developers with profiling, thread optimizing, and code covering their applications. If the JVM runs a Java application, Optimizeit Suite can attach to the application and display the memory, thread, and other information in a userfriendly way, which helps the developers to optimize their applications. Optimizeit Suite is a very flexible tool, and it can attach with various market leading IDEs and application servers. Visit the link http://info.borland.com/techpubs/optimizeit/ to find the supported J2EE application servers, documentation, and other information about Optimizeit Suite. For this case, let s attach Optimizeit Suite with WebLogic Server 7.x. Click the Optimize icon from JBuilder main menu bar and click TestJSP. The Runtime Configuration Properties window pops up and allows users to select one of the three tools (Profiler, Thread Debugger, and Code Coverage). Select Profiler from the combo box and click OK. See Figure 11 for details. 23

Figure 11: Runtime configuration window to choose which Optimizeit Suite tool to use Click OK and WebLogic Server 7.x starts within JBuilder 8. Note that Optimizeit Profiler is attached to WebLogic Server 7.x and profiling the real-time JVM information. To run your TestJSP, right-click the JSP. Click WebRun. Click TestJSP. See Figure 12 for details. 24

Figure 12: Optimizeit Profiler attached to WebLogic 7.x within JBuilder 8 To go to the normal WebLogic output window, click the Console output, input and errors icon from the left. Also, you can click Show Virtual Machine information and Show CPU profiler for different operations. The Profiler shows information about all the classes available in the JVM. If you would rather see the information about your application only, type borland* in the Filters text area. This will show you the packages started with borland only. To attach Optimizeit Thread Debugger with WebLogic Server 7.x, click Run -> Configurations -> select TestJSP -> Edit -> click Optimize -> Select Thread Debugger from the Type combo box. See Figure 13 for Optimizeit Thread Debugger starting in JBuilder and attaching WebLogic Server 7.x. 25

Figure 13: Optimizeit Thread Debugger started in JBuilder 8 and attached with WebLogic Server 7.x Optimizeit Code Coverage can be started in the similar way. See Figure 14 for Optimizeit Code Coverage tool within JBuilder 8. Figure 14: Optimizeit Code Coverage tool started and attached to WebLogic Server 7.x There are lots of features available in Optimizeit Suite that helps detecting critical memory leaks, deadlocks, and performance issues. This paper just explained a snapshot of some of the features of Optimizeit Suite. Please read the Optimizeit Suite product documentation for information about other features of Optimizeit Suite. Working with Apache Struts What is Struts? The Struts open source framework is known as the Model 2, or Model-View Controller, approach to software design. This framework evolved from the Model 1 design, JavaServer Pages technology. This technology offered great advances from pure servlets, where 26

presentation HTML was coded with lengthy out.println statements in doget() and doput() methods. JSPs offer a way to include HTML in Java code and Java code in HTML. However, these JSPs are difficult to read and difficult to maintain, because both Web designers and developers are required to work in the same set of source files. The Struts framework, first developed in 2001, combines the best of servlets and JSPs. The framework consists of a 3-tiered design paradigm: the Controller, Model, and the View. Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. Using the Struts framework is now the preferred way to create robust and long-lived professional Web applications. For learning more about Struts, please visit http://jakarta.apache.org/struts/index.html. If you have installed JBuilder 8, you can also get information about Struts from JBuilder Help. Create a Struts application Struts is the next generation Web application development framework. But Struts applications can be difficult to write. A Struts application development cycle is probably two or three times longer than the conventional Web application development cycle. But JBuilder makes the Struts application development much easier for the developers. The easier-to-use code wizards of JBuilder can create the Struts infrastructure efficiently and eliminate lot of hand coding. With the help of JBuilder, the developers now can focus on the business aspect of their application rather than framework development and configuration. While JBuilder is capable of creating very complex Struts applications, let s create a simple login application (with Struts implementation) to understand the basic guidelines. Create a New Project in JBuilder 8 and name the project StrutsProject. Note :For this exercise, the location of the project is E:/DEMO/TESTWLS/StrutsProject. 27

Make WebLogic Server 7.x as the target server for this project. Click Project -> Project Properties -> Server tab and make sure that WebLogic Application Server 7.x is selected from the combo box. Create a Web application and enter the Web application Name and Directory as LoginApp. Select Struts 1.0 under JSP/Servlet frameworks in the Web Application Wizard. Click OK. Expand the Web application LoginApp in the JBuilder project tree. Note that strutsconfig.xml is already created for this Struts application. Figure 15 shows the JBuilder Web Application Wizard, which allows the user to choose Struts 1.0. 28

Figure 15: JBuilder provides wizards to create a Struts Web application Note: JBuilder 8 does not officially support the beta release of Struts 1.1. However, if you enable your struts-config.xml file for Struts 1.1 and download the Struts 1.1.jar file to the <jbuilder>/extras folder, you will see support for Struts 1.1. The Struts Config Editor will display elements and attributes specific to 1.1. Additionally, if your Struts Web application uses a tiles.xml file for presentation, a visual editor for the Tiles configuration file is available. Create two JSPs (login.jsp and message.jsp) using the JBuilder JSP wizard. Note that JSP Wizard Step 2 of 4 allows users to select Struts taglibs. See Figure 16 for details. 29

Figure 16: JSP Wizard allows users to select Struts taglibs For this exercise do not select any tag libraries. Edit login.jsp and message.jsp in JBuilder editor and copy the following code: login.jsp <html> <head> <title>login Page</title> </head> <body> Please enter your user name and password <br> 30

<form action="loginaction.do" method=post> <table> <tr> <td>user Name:</td> <td><input type=text name=username> </tr> <tr> <td>password:</td> <td><input type=password name=password> </tr> <tr> <td colspan=2 align=right><input type=submit value="login"></td> </tr> </table> </form> </body> </html> Table 4: login.jsp: the primary JSP for this Struts application message.jsp <html> <head> <title> message </title> </head> <body bgcolor="#ffffff"> <h1>login Successful</h1> </body> </html> 31

Table 5: message.jsp: this JSP activates after a successful login Note: login.jsp is the primary JSP for this application. It accepts username and password. Message.jsp displays a message to the users after successful login. login.jsp and message.jsp represent the View layer in this Model 2 Struts application. Create a Struts Action using the wizard from JBuilder Object Gallery. From Object Gallery, select Web tab, click Action and click OK. In Action Wizard Step 1 of 2, enter the package name as borland.demo.struts and Action as LoginAction. In Action Wizard Step 2 of 2, click the ellipses against Input JSP and select login.jsp from the pop-up window. Click Finish. The above wizard creates a file called LoginAction.java. Find the file from the JBuilder Project tree and edit is as shown in Table 6. LoginAction.java package borland.demo.struts; import org.apache.struts.action.*; import javax.servlet.http.*; import javax.servlet.requestdispatcher; import java.io.ioexception; import javax.servlet.servletexception; public class LoginAction extends Action { public ActionForward perform(actionmapping actionmapping, ActionForm actionform, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws IOException, ServletException { 32

String username = httpservletrequest.getparameter("username"); String password = httpservletrequest.getparameter("password"); System.out.println("Username provided =" + username); System.out.println("Password provided =" + password); if (username!=null && password!=null && username.equals("suds") && password.equals("borland")) { return new ActionForward("/message.jsp"); } else { return new ActionForward("/login.jsp"); } return null; } } Table 6: LoginAction.java: implementation of action Note: The LoginAction.java file implements the action which is defined in the login.jsp. Note the following line from login.jsp. <form action="loginaction.do" method=post> The LoginAction gets the username and password parameters, checks the authentication and then commands the RequestDispacher to run either message.jsp (upon successful login) or login.jsp (upon unsuccessful login). For simplicity, the authentication for username is suds and password is borland. The <action-mapping> is available in the struts-config.xml file. Take a look at this file. It demonstrates how the loginaction.do in the login.jsp is mapped to the LoginAction class. The.do is a conventional representation of the URI. Open the web.xml and check for the 33

servlet-mapping for servlet-name action. The url-pattern for action is *.do. Also action is nothing but an instance of the Controller Servlet org.apache.struts.action.actionservlet. struts-config.xml <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd"> <struts-config> <action-mappings> <action type="borland.demo.struts.loginaction" input="/login.jsp" path="/loginaction" /> </action-mappings> </struts-config> Table 7: struts-config.xml Deploy and run the Struts application Now run the project (click F9 or click Run Project icon then login). WebLogic Server 7.x is designed to start within JBuilder and permit you to see the running login.jsp in the AppBrowser. See Figure 17 for details. 34

Figure 17: JBuilder running Struts application using WebLogic Server 7.x Enter the user name as suds and password as borland. It is designed to show you the Login Successful message. Try entering some other information, and it should bring the normal login.jsp screen again for re-entry of user name and password. Conclusion JBuilder is a highly productive environment, and users can increase their productivity and reduce the project lifecycle by using JBuilder as a Java development platform. This paper is focused only on JSPs, servlets, and Struts applications. JBuilder has many other features which are designed to make the Web development a smooth experience for the developers. If you have JBuilder installed, try the tutorials available in JBuilder Help. Also refer to other white papers available on the Borland Web site for EJB and Web Services development. Troubleshooting Error 1: WebLogic Server cannot start: config.xml not found Error description <Info> <Management> <140013> <E:\bea\user_projects\.\config.xml not found> E:\bea\user_projects\.\config.xml not found Since no config.xml was found, the filerealm.properties file will not be used. 35

Would you like the server to create a default configuration and boot? (y/n): When did this happen I tried to run WebLogic Server from JBuilder and got this error from WebLogic 7.x http:7001 tab. Cause The Domain Directory provided in JBuilder Server Configuration may not be correct. Solution From the JBuilder menu bar, click Tools -> Configure Servers. Click WebLogic Application Server 7.x from the left-hand pane, and click Custom tab from the right. Check the Domain Directory. An example of Domain Directory is E:\bea\user_projects\mydomain. Error 2: Authentication for user <username> denied Error description <Critical> <WebLogicServer> <000364> <Server failed during initialization. Exception:java.lang.SecurityException: Authentication for user username denied When did this happen I tried to start WebLogic Server 7.x within JBuilder and got this error from WebLogic Server 7.x http:7001 tab. Cause The username or password provided in JBuilder to configure with WebLogic Server may not be correct. 36

Solution From the JBuilder menu bar, click Tools -> Configure Servers. Click WebLogic Application Server 7.x from the left, and click Custom tab from the right. Re-enter the correct user ID and password. Error 3: Help viewer error on server in AppBrowser Error Description Help viewer error on server Unable to open location: Document not found on server. When did this happen: I tried to run a JSP/servlet from JBuilder, and the AppBrowser shows this error. Cause The error confirms that the WebLogic Server is running properly, but the document JSP/servlet that you are trying to access is not found in the WebLogic server. Solution Redeploy the Web application and try to run the JSP/servlet again. Error 4: Deployment of Web application failed Error description Exception:weblogic.management.ApplicationException: Prepare failed. Task Id = 0 Module: TestWebApp Error: weblogic.j2ee.deploymentexception: Cannot deploy ServletContext(id=2545674,name=TestWebApp,contextpath=/TestWebApp) from E:\bea\user_projects\mydomain\myserver\upload\TestWebApp\TestWebApp.w ar on myserver because there is already a webapp named 37

ServletContext(id=5684736,name=TestWebApp,context-path=/TestWebApp) loaded from E:\Documents and Settings\spati\jbproject\TestWebApp\TestWebApp, which is using the context path /TestWebApp. When did this happen I tried to deploy my Web archive from JBuilder to WebLogic by right-clicking the WAR file > Deploy Options -> Deploy. Cause Seems like you have already deployed a Web application with the same name to WebLogic Server. Solution By default, JBuilder maps the project Web applications to WebLogic at runtime. This is called auto-deployment or exploded format deployment. Auto-deployment does not require any WAR or EAR files. WebLogic knows where to find the updated JSPs, servlets, and Java files. But if you rather use the hot deployment (deploying archives), turn off the exploded format deployment. Click Project -> Project Properties. Click the Server tab. Click the JSP/servlet service in the services list. On the right, de-select the option Map project webapps at runtime. Now you can deploy your WAR/EAR without any deployment conflicts. Error 5: Unable to load performance pack Error description <Error> <socket> <000433> <Unable to load performance pack, using Java I/O instead. Please ensure that wlntio.dll is in: 38

'E:E:/bea/weblogic700/server/bin' java.lang.unsatisfiedlinkerror: no wlntio in java.library.path When did this happen This happened when I started WebLogic Server 7.0 within JBuilder 8. The error appeared within WebLogic Server 7.0 http:7001 tab, and the server didn t start. Cause This error occurred because the VM parameters of Configure Servers are not correct. WebLogic is unable to find the wlntio.dll because the path information for E:/bea/weblogic700/server/bin is not correct. Solution Click Tools -> Configure Servers ->. Click WebLogic Application Server 7.x from the left-hand pane and click VM Parameters from the right-hand pane. Make sure that -Djava.library.path has correct path information. Warning 1: Deprecation warnings Warning description "TestJSP.jsp": Warning #: 368 : method putvalue(java.lang.string, java.lang.object) in interface javax.servlet.http.httpsession has been deprecated at line 8 Warning #: 369: There have been deprecation warnings. Please consult the documentation for a better alternative When did this happen Whenever I compile/build my project, I get a separate build tab in the JBuilder message pane, and these warning messages show there. Also, this happens when I start my WebLogic Server within JBuilder and deploy my archives to WebLogic. 39

Cause Some of the methods created by JBuilder Wizard are deprecated. Solution: From JBuilder main menu bar click Project Project Properties Build tab and uncheck Show Warnings and Show deprecations. Warning 2: Servlet failed with ServletException Warning description <Error> <HTTP> <101018> <[ServletContext(id=6655097,name=TestWebApp,contextpath=/TestWebApp)] Servlet failed with ServletException javax.servlet.unavailableexception: ServletContext(id=6655097,name=TestWebApp,context-path=/TestWebApp): The server myserver is temporarily suspended at weblogic.servlet.internal.webappservletcontext.invokeservlet(webappse rvletcontext.java:3077)at weblogic.servlet.internal.servletrequestimpl.execute(servletrequestim pl.java:2544) at weblogic.kernel.executethread.execute(executethread.java:153) at weblogic.kernel.executethread.run(executethread.java:134) When did this happen I have started WebLogic 7.x successfully within JBuilder. When I click Run Project -> TestJSP from JBuilder toolbar, WebLogic Server starts within JBuilder but shows this error in the message. 40

Cause Sometimes the JSP is activated before the initialization of WebLogic Server which causes this error. Solution: This is a harmless warning message and doesn t effect anything. If you would rather not see this warning message, then open the WebLogic Console ( Tools -> WebLogic 7.x Admin Console), expand Servers -> click myserver -> from the right-hand window, click Logging - > change the Stdout severity threshold from Error to Notice. Click Apply. Useful links JBuilder WebLogic Edition product information http://www.borland.com/jbuilder/weblogic/ JBuilder WebLogic Edition download http://commerce.bea.com/downloads/jbuilder.jsp JBuilder online documentation http://info.borland.com/techpubs/jbuilder/jbuilder8/index1280x1024-ent.html Optimizeit Suite online documentation http://info.borland.com/techpubs/optimizeit/optimizeit5/index1280x1024.html Configuring Optimizeit Suite with WebLogic (to run outside of JBuilder) http://info.borland.com/techpubs/optimizeit/optimizeit5/integ_guide/weblogic7.html Borland JDataStore http://www.borland.com/jdatastore/index.html Link to other JBuilder white papers 41

http://bdn.borland.com/all/0,1435,s 50092 13,00.html JBuilder OpenTools http://codecentral.borland.com/codecentral/ccweb.exe/prodcat?prodid=3&catid=11 Feedback and suggestions Please send your feedback and suggestions to: Sudhansu Pati, Systems Engineer [spati@borland.com] 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com 831-431-1000 Fax: 831-431-4142 Made in Borland Copyright 2003 Borland Software Corporation. All rights reserved. All Borland brand and product names are trademarks or registered trademarks of Borland Software Corporation in the United States and other countries. Corporate Headquarters: 100 Enterprise Way, Scotts Valley, CA 95066-3249 831-431-1000 www.borland.com Offices in: Australia, Brazil, Canada, China, Czech Republic, France, Germany, Hong Kong, Hungary, India, Ireland, Italy, Japan, Korea, the Netherlands, New Zealand, Russia, Singapore, Spain, Sweden, Taiwan, the United Kingdom, and the United States. 20151 42