AFAIK when a bean raises an exception that is passed to a JSP (by this
time compiled into a servlet), all processing will be stopped when
the exception is thrown (the exception is effectively caught by the
errorPage).

If you're catching the exception in the method that's causing the
exception (i.e. wrapping code in try{} catch{} blocks) then
processing will continue in the catch block when an exception is
thrown. If you don't stop the processing in the catch block by
returning or whatever, then the remainder of the method will be
processed after falling out of the catch block.

So the solution to your problem as I understand it is to make
methods throw exceptions rather than to use try/catch and make
sure you write errorPage pages to catch them at the top level.

For example, do:

        public void method() throws java.io.IOException {
                ...
                File f = new File( ... );
                ... more processing that WON'T be done if previous line
throws exception ...
        }

or:

        public void method() {
                ...
                try {
                        File f = new File( ... );
                } catch(java.io.IOException e) {
                        .. handle exception ...
                        return;
                }
                ... more processing, which WON'T be done if exception thrown
...
        }

rather than:

        public void method() {
                ...
                try {
                        File f = new File( ... );
                } catch (java.io.IOException e) {
                        ... handle exception, but don't return ...
                }
                ... more processing, which WILL be done in the event of an
exception ...
        }


        -Duncan

-----Original Message-----
From: Kai Hackemesser [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 20, 2000 3:39 PM
To: [EMAIL PROTECTED]
Subject: An exception occurs on my page... how to stop the whole page
processing?


Hi!

I want to know how I can stop the page processing of a JSP page when an
exeption has occured and I have shown the message.

on ASP it was response.end, and here?

ciao!
Kai

===========================================================================
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

===========================================================================
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

Reply via email to