Hi all:
Since full debugging of JSP's is a regular topic of interest, and I have
just spent the last 2 days figuring out how to do it, I thought I would
share it with you.
IBM VisualAge 3.0 Professional Edition for Windows has integrated support
for standalone debugging of servlet's and JSP's. JSP debugging support is
available for both the 0.91 and 1.0 JSP spec. (I assume the Linux version
also supports this, but I have not tried it.)
Debugging support is enabled via a self-contained http server, servlet
engine and JSP runtime that come with the VisualAge (VA) IDE. You do NOT
need a separate copy of either WebSphere Application Server, nor WebSphere
Studio to debug your servlet/JSP's.
Your servlet's and JSP's are invoked from any standard webbrowser, making
http requests to the localhost listening on port 8080. For example:
http://127.0.0.1:8080/servlet/Hello , will invoke the 'Hello' servlet
defined in your VA Workspace.
The Servlet debugger allows you to:
* Step through each line of the Java code in your servlet.
* Set breakpoints before the servlet is executed
* Fully inspect all Java object instances
The JSP debugger allows you to:
* Step through each line/html block of your JSP
* See the matching Java source code for each line of your JSP.
* See the HTML output as it is emitted, one line at a time.
Configuration:
* You must add the debugging support to your VA workspace. To do this, you
load 2 support projects into your VA Workspace:
File -> Quick Start -> Features ->Add Feature -> select: 'IBM JSP Execution
Monitor' + 'Sun Servlet API 2.1'
, this will automatically include the following projects:
IBM JSP Execution Monitor
IBM WebSphere Test Environment
IBM Servlet IDE Utility class libraries
IBM Data Access Beans (required, in order to work with the IBM JSP Examples)
Sun Servlet API 2.1
* The default web server document root (where it finds HTML, JSP, images
etc...) that file://127.0.0.1:8080/ is mapped to is:
\IBMJava\Ide\project_resources\IBM WebSphere Test
Environment\hosts\default_host\default_app\web\
, so you need to copy your site tree (except for the servlets!) to this
directory if you want to use the default.
Optionally, you can change the 'docroot' property in the file:
\IBMJava\Ide\project_resources\IBM WebSphere Test
Environment\SERunner.properties , and point it somewhere else.
Note that your servlets run from within the VA Workspace (VA stores Java
source and class in an internal repository - NOT on your file system. You
get files in/publish them out using import/export utilities.), and NOT the
docroot tree.
To get the debugger working with JSP 1.0 requires making a change to a
configuration file, since the default support only works for JSP 0.91.
* Change the property in the WebSphere servlet configuration file:
\IBMVJava\ide\project_resources\IBM WebSphere Test
Environment\hosts\default_host\default_app\servlets\default_app.webapp
Change from:
...<description>JSP support servlet</description>
<code>com.ibm.ivj.jsp.debugger.pagecompile.IBMPageCompileServlet</code><init
-parameter>...
to:
...<description>JSP support servlet</description>
<code>com.ibm.ivj.jsp.runtime.JspDebugServlet</code><init-parameter>...
Execution:
Servlet/JSP execution + servlet debugging is invoked by running the
com.ibm.server.SERunner.class, which instantiates a WebSphere test
environment, which includes http, servlet and JSP support.
The VA 3.0 IDE has a menu option that invokes SERunner: 'Workspace ->
Tools -> Launch WebSphere test environment'
However, the menu option does NOT work with JSP 1.0 support! (With JSP 0.91,
it works like a charm, and happily finds all the classes it needs to
generate/compile/execute/debug your JSPs.)
Instead, you need to configure and launch SERunner from your workspace:
1. Add your project to the SErunner classpath:
>From the 'IBM WebSphere Test Environment' project, choose the SERunner
class, and select the 'Run -> Check class path...' context menu option.
>From the 'Class Path' tab, you want to 'Edit...' the 'Project Path' and add
your project(s) that contain your servlet(s).
2. Run Serunner:
>From the 'IBM WebSphere Test Environment' project, choose the SERunner
class, and select the 'Run -> Run main...' context menu option.
(If you set breakpoints in any servlet from within the IDE, it wil
automatically stop at them, and open the debugger window when your servlet
gets invoked via your web browser.)
If you want to debug your JSP's, you also have to start the JSP Execution
Monitor. You start this from the main menu with: Workspace-> Tools -> JSP
Execution Monitor.
For full debugging support, choose both:
'Enable monitoring JSP execution'
'Retrieve syntax error information'
, from the JSP Execution Monitor Options dialog that pops up.
Thats it. When you invoke a servlet from your web browser, and breakpoints
have been defined in it, it will pop up in the debugger window.
If your servlet calls a JSP, or you invoke a JSP directly from your browser,
the JSP Execution Monitor window will automatically appear, allowing you to
step through the JSP from the first line, viewing the Java source, and
watching the output.
Issues I have not figured out (yet):
* If your servlet is in a package, for example, ihippo.util.Hello.class,
what URL do you use from your browser?
* The engine seems to magically find any servlet that is not in a package,
regardless of the VA project, as long as you use the URL prefix:
file://127.0.0.1/servlet/. Seems like a little black-magic to me.
* I do NOT know how to set up aliasing, mapping, chaining and filtering. I
have only got it to work with straight 1-to-1 mappings between servlets/JSps
and URL.s
* How do I debug the JSP generated code from within the debug window? I
expect to be able to find my generated class in the 'JSP Page Compile
Generated Code' project and the 'jsp' or 'pagecompile._jsp_debug' packages,
set the breakpoint, and have it pop up. However, setting breakpoints in
either of these classes didn't have any effect.
Other notes:
* WebSphere is VERY case-sensitive, even on NT. You must type in directory
names exactly as they are on your file system.
* Make sure all beans passed between servlets and JSP's have a null
constructor - otherwise the error message is an exercise in obfuscation.
One major observation is that VA + the debugging upport is a memory PIG. I
have 128M RAM on my PC and find that my hard-drive is thrashing a lot. I
intend to upgrade my RAM to 512M to speed things up. (I know that WebSphere
Application Server 3.0 Standard Edition takes 512M RAM at a minimum - just
for the engine - that doesn't even cover your application's memory/caching
requirements!)
VA 3.0 Professional Edition costs $149 USD by buying a subscription to IBM's
online Visual Age Developer Domain service (VADD). It is the best $149 I
have spent in ages. I had used JBuilder for years before Wednesday, and
just uninstalled it, since end-to-end debugging support is super-critical to
me. I had never even seen VA before, and it is definitely 'different', but
if you have serious debugging tasks ahead of you, you might want to consider
it.
I have not made a final decision on what runtime environment I will use, but
I am a bit scared of WebSphere, as it seems to be such a resouce PIG. I am
leaning towards the Resin product from Caucho, and assume that I will be
able to export my servlets and classes into a JAR file that will work
unchanged with Resin. I will let you know how this turns out.
Cheers,
Ian
PS - Please feel free to share/repost this, but if you add more
information/insights - you are morally obligated to email me a copy. Thanks.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html