Graham Cruickshanks wrote:
> Problem, It's a pain debuging runtime errors in these javabeans, by running
> them in jsp pages and getting output,
>
> Is there a easy way to debug and run javabeans before i use them in the jsp
> pages?
You might consider using one of the Java-based scripting languages such
as JPython (http://www.jpython.org/) or Jacl
(http://www.scriptics.com/java/ or the latest version at
http://www-users.cs.umn.edu/~dejong/tcl/tcljava/prerelease.html).
One nice feature of these scripting languages is that you can start up a
command-line interpreter and instantiate/modify/examine objects
on-the-fly. Most of my experience is with Jacl, so I'll use it for
these examples.
jaclsh
% package require java
1.2.6
% set bean [java::new com.blah.MyBean]
MyBean@0F00
% $bean getName
Bubba
% $bean setName Vern
Vern
and so forth. The real interesting part is when you notice that you
have both a full-fledged scripting language (not just a command-line
interpreted Java) and you have the full power of reflection --
% foreach method [java::info methods $bean] {
if {[llength $method] > 1} continue
if {[string match get* $method] || [string match is* $method]} {
puts "$method=[$bean $method]"
}
}
The above loops through all the methods in your bean, printing out the
value of all your getXXX and isXXX accessors.
The next step beyond the above is to build a set of test procedures and
regression tests for your beans. If you download the Jacl source, you
will see that it comes with its own set of regression tests based on the
very compact tcltest framework. You basically build little code
snippets like:
test testName-N.M "Description of test" {
bunch of code to set up objects and call methods
} {expected output of last statement in above code}
With this, you can start building up a set of test cases for both
positive (non-error) and cases where you expect errors to occur. Every
time you find a bug in your code, you add a test case that reproduces
the bug -- BEFORE you even fix the bug. Then after you fix the bug,
re-run the test suite to ensure you didn't break something else.
Hope this helps,
-=- D. J.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets