At first I was like "What?"  Then the answer dawned on me.

You introduced a syntax error into the JSP, viz., an undeclared variable
named "b."  So what you're seeing this time is, again, a compiler error,
but this time it's a normal one.  Jikes isn't doing anything tricky.

The errorPage page directive attribute/feature of JSP is for _runtime_
exceptions that might occur, not for compilation exceptions.  Now I see
what I didn't make clear in that section of the chapter!  Sorry about
that.  But it raises a good point.

If you'd done a valid syntactic thing, like:

<% String foo = null; %>
<%=  foo.getClass() %>

Then you'll compile through OK, but get a runtime exception when you try
to call a method on a null (NullPointerException).  This is what
errorPages are for -- you're kind of on your own for compile-time
exceptions.

Similarly, you can do the same thing by tricking Jikes to ignore that
baldfaced divide-by-zero by assigning the values to variables:

<% int a = 1; int b = 0; int c = a/b; %>

However, you can configure JRun at the server level, and maybe web-app
too (I'd have to check the docs) to return a pretty error page even on
the JSP compile-time errors.  In this case, though, it's a proprietary
feature of JRun, and more of a Web server feature than anything to do
with JSP.  In this case, Jrun will just put up the error page on any 500
error, regardless of whether it's related to JSP compile/runtime
problem, servlet exception, server crash, etc.

Hope this helps.

Best,

Scott Stirling 

On 17 Jan 2001 22:33:34 -0500, Scott Stirling wrote:
> 
> 
> -----Original Message-----
> From: Marc Garrett [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 17, 2001 4:48 PM
> To: JRun-Talk
> Subject: Re: Exception Handling: Still Can't Get it to Work. Please Help
> 
> 
> Scott,
> 
> Thanks for your continued assistance.
> 
> I changed my compiler back to jikes. I then changed the expression from "1 /
> 0" to "1 + b" in order to throw an error other than divide by zero. JRun
> still reports the error directly on the page instead of changing to the
> exception handling page.
> 
> I didn't mean for this to turn into a time-sink for you. :-)  Mainly I'd
> like to have a rudimentary way to handle exceptions while I'm still learning
> Java. The example from ch. 4 would be great if I could get it to run on my
> machine.
> 
> Here's my code that sets up compiler services:
> 
> jsp.javac-in-proc.class=allaire.jrun.scripting.JavaCompilerService
> 
> jsp.jikes.class=allaire.jrun.scripting.JavaCompilerService
> jsp.jikes.compiler={jrun.rootdir}/bin/jikesw +E -g -nowarn -d %d %f
> jsp.jikes.error.regexp=\\([^:]*\\):\\([0-9]*\\):[0-9]*:[0-9]*:[0-9]*:\\([^\n
> ]*\\)[\n$]
> jsp.jikes.error.regexp.filesubexpr=1
> jsp.jikes.error.regexp.linesubexpr=2
> jsp.jikes.error.regexp.errorsubexpr=3
> 
> Thanks,
> 
> Marc Garrett
> 
> 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to