Home > AS/400 Tips > WebSphere Strategies for iSeries professionals > Debug Web applications easily with WDSC
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

WEBSPHERE STRATEGIES FOR ISERIES PROFESSIONALS

Debug Web applications easily with WDSC


Jim Mason, Search400.com expert
04.01.2004
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


WebSphere Development Studio Client (WDSC) offers a variety of tools to help developers easily debug applications in many environments:

If you're new to Web development with WDSC, this article can help make your experience testing and debugging web applications easier.

WDSC provides many advantages for new Web developers to test and debug Web applications:


[TABLE]

Developers NOT using WDSC to debug and test Java Web applications are often either extremely advanced or in trouble.

JPDA provides Java platform runtime debug support

Sun designed the Java platform to support remote debugging of applications running in the Java Virtual Machine (JVM). A Java API, Java Platform Debug Architecture (JPDA), specifies three debug interface levels for a debug tool or application to debug a JVM.

The Debug support includes three APIs (from easiest to hardest) to implement:

The IBM Distributed Debugger can attach to a JVM IF the JVM is started in debug mode. Since WebSphere and Tomcat run on JVMs, they can be debugged remotely by the IBM tools when started in debug mode.

IBM's WDSC leverages the JPDA architecture and the IBM Distributed Debugger tool to make debugging any application in any environment an easy task.

WDSC Eclipse workbench debugs regular Java apps

The basic Eclipse platform provides an excellent debug tool for Java applications running in the Eclipse workbench. Using the tool, you can set breakpoints, view and change variable values and change code in Java applications from the debugger. It also gives you "standard" debug navigation through your code:

The WebSphere Test Environment makes Web testing easy

With the built-in WebSphere test environment, you can run and test any Web application easily with one click of a button. No, this ISN'T IBM marketing hype. It's REALLY true! While the real WebSphere App


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Web Tools
Programming for the Web on the IBM i, what is possible
Zend Web software teams up with IBM System i
Using geocoding on AS/400 to enhance your Web presence
The iSeries Blog has a new home on IT Knowledge Exchange
The best technologies and tools for System i programmers in 2009
Search400.com Products of the Year 2008
Application modernization strategies for System i
Natively supported Web applications for Power running i
System i PHP authoring tool tries to fill void in Web-coding know-how
Lazy coder: What does PHP on the i5 mean?

Web Servers
System i no longer the stepchild of IBM's world
Connecting WebSphere to AS/400 for image retrieval
Weaving in WebSphere
SOA enhancements drive IBM WebSphere feature packs
SOA means money for IT workers
Enable J2EE app on WAS to access DB2
Securing Apache: Keeping patches current
IBM runs USOpen.org on Power boxes
MoMA's IT makeover a mix of old and new
How does RPG talk to a browser?

WebSphere Strategies for iSeries professionals
Application modernization strategies for System i
Application modernization in the i world
Natively supported Web applications for Power running i
Enterprise open source basics
Basic security considerations for a Domino/WebSphere system
Simplifying data access using Java Standard Tag Library
Integrating Microsoft ActiveX components with WebSphere
Choices for running Web workloads on iSeries
Virtual hosting for iSeries Web applications
Automate WebSphere configuration backups on the iSeries (i5)

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
WebSphere Development Studio Client (WDSC)  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


lication Server HAS become easier to administer in version 5, it's still challenging for most people to learn how to configure and manage applications in WebSphere well. IF you have experience with an earlier version of WebSphere, you won't believe how easy the WDSC WebSphere Test Environment is.

After you have created a Web application, just select the main page to launch the application (often index.html), right click to get the object menu, and select "Run on Server". That's it! WDSC then AUTOMATICALLY does the following:

For most developers creating Web applications that may be ALL you'll ever need to know about WebSphere administration.

Our company, ebt-now, specializes in building Web applications for iSeries customers and training their developers with custom workshops on WDSC. We use the WebSphere Test Environment extensively. With a Web application running in the test environment, we can connect to back-end iSeries servers (ours or the customer's) over the Web. We then provide our customer with a URL to access their application IN our test server. Users can then run and test the Web application easily WITHOUT having to install WebSphere Application Server, Tomcat or any other J2EE server.

Debugging in the WebSphere Test Environment is simple

IF you have a runtime error testing your application, you can debug it easily with the WebSphere Test Environment.

Setup to debug a Web application

To debug a Web application, just do the following:

Figure 1 shows how to launch your application in debug mode AFTER starting the test server in debug mode.

[TABLE]

Running in debug mode

Once your initial page is loaded in the WDSC test Web browser in the workbench, run your application normally.

When your application runs a Java class with breakpoints set, the debug perspective opens and you can see the method source that is executed at that point. You can change variable values or the code.

When your application runs a JSP or servlet, a pop-up dialog asks you if you 1) want to "STEP INTO" this JSP or servlet and execute it line by line OR 2) "SKIP OVER" this JSP. In "STEP INTO" mode, you execute each line of the JSP or servlet as it is highlighted in the debug browser. In "SKIP OVER" mode, the JSP or servlet just runs without stopping unless a breakpoint is reached.

You also have the option to disable "Step by Step" mode on the "Step by Step Debug" dialog. If you disable it, the application will stop only when it encounters breakpoints you've set in a JSP or Java class. If you're interested in only a specific error, this saves time, since you set only one breakpoint and go right to the portion of the application without debugging other items first.

"STEP INTO" mode is useful when you are trying to understand how the Web application works. Again, "SKIP OVER" mode is useful when you are focusing on one specific spot in your application with a breakpoint set.

Figure 2 shows the pop-up dialog for "Step by Step" mode on a JSP service method.

[TABLE]

Figure 3 shows the source in the WDSC debug view for a JSP. The top left pane has the execution stack. The top right pane displays the variable values for the current method. The bottom pane shows the JSP source code for the currently executing JSP.

[TABLE]

Save the Java source when a JSP is compiled to a servlet

Normally, JSP compilers will read JSP source files and generate Java servlet classes that are executed in your Web application at runtime WITHOUT saving the Java source for the generated servlet class. That makes it difficult at times to link a typical stack trace on a servlet from a runtime error to the matching JSP code that created the problem. You can save the Java source that is generated from a servlet in the WebSphere Test Environment by modifying an IBM configuration file in your Web project. (In the WEB-INF folder look for file: ibm-web-ext.xmi.) Then publish your application to your specific test WebSphere server instance.

The code below shows the changes I made to the ibm-web-ext.xmi file to save the generated Java servlet source for an application:

I specified a true value for the "keepgenerated" parameter, and I set the "scratchdir" value to "c:tempdebug".

Use the stack trace information to locate a problem in a JSP

Often the stack trace has enough detail to make it clear where the actual problem is in your JSP. If it doesn't, you can trace the cause of the problem to the JSP by doing the following:

Figure 4 shows the JSP stack trace from a compile error that points to the generated servlet source line in error.

[TABLE]

Figure 5 shows the generated servlet source line in error with the comment pointing to the matching JSP lines.

[TABLE]

Other debugging tips

Some other items you might be interested in using in a Java web debug scenario include the following:

ebt-now JspLogger
In our WDSC workshops, we provide a EVP.jar file (ebt-now Visual Parts) that contains a Java class (JspLogger) that can easily list selected request, session or application attribute values to the System console. This can reduce the need to run traces to find problems. If you have a skilled Java developer in-house, you can write the same reusable test class.

IBM Distributed Debugger can debug ANY Java environment
The Distributed Debugger is a VERY powerful tool buried in WDSC WebSphere Test Environment wizards. You can run the tool in standalone mode to debug Java Web applications running in environments outside of WDSC: Tomcat, WebSphere, etc. The Distributed Debugger can launch Java applications OR attach to running Java applications on a port (such as a Web application server). The only negative is the Distributed Debugger requires a higher level of Java skill to run.

More information on WDSC web development and debugging

If you're an iSeries RPG developer, another option is the WDSC self-study course I'm writing. It fits scenarios in which you won't have the time or money to become a Java expert BEFORE building e-business applications with WDSC. The VDM approach in that course teaches you how to visually build e-business applications WITHOUT needing to become a Java expert. The "hands-on" labs teach you how to build all types of WDSC applications using WDSC visually using Page Designer and JSP tag libraries. Rochester Initiative will publish this course later this spring.

---------------------------------------

About the author: Jim Mason, president of ebt-now, is an iSeries WebSphere architect, trainer and developer. ebt-now provides iSeries WebSphere, WebFacing engineering, development and training services. You can reach Jim at jemason@ebt-now.com.

Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts