The only way I know of to solve this problem is to declare your bean as an
instance variable for the servlet, something like this:

<%!
     private myclass c = new myclass(); // construct our bean the old
fashion way
     .....
%>

    The object c is now visible to all methods in the compiled servlet


-----Original Message-----
From: Alessio C. [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 1:05 AM
To: [EMAIL PROTECTED]
Subject: Re: Closing a DB connection used in a bean


> It's because all the implicit objects
(request,session,response,out,etc.),
> your beans using the jsp tags and any other object declared inside
the "<%
> ... %>" tags are all local variables inside the service method of the
> compiled code.  This is automatically done by the JSP engine - you
can't, to
> my knowledge, override this behavior.  If you want these objects to be
> visible to your custom methods, you will have to pass them as
arguments to
> your custom methods.

Ok, but i've to override the jspInit() & jspDestroy() methods, and they
don't have arguments....
A way to pass a bean would be:
<jsp:useBean id="b" class="myclass" scope="page"/>
....
<!% public void jspDestroy() {
     myclass c;
     c.mymethod();
}
%>
....
<% c = b; %>

but it's not a nice way (and i don't know if it would work...)

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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