Robert Nicholson wrote:
>
> I'm interested in a response to the question so I'll ask the question again.
>
> The site I'm at has factored a lot of useful functionality into a
> HttpJspPage superclass and makes use of "extends" on all jsp pages.
>
> What I want do know is that since I'm developing my stuff so that I'm using
> servlets to do most of the processing of forms etc I want to know the best
> way of getting at the instance of the page because I need to call instance
> methods on it. Things like getting a database connection, doing common
> database queries etc, logging to custom log files are all instance methods
> of the page.

Can't you just use the HttpJspPage class as a utility class in your servlet?
The fact that it's intended to be used as a base class for JSP pages doesn't
prevent you from using it as a regular Java class.

> Other than by putting it into the users session. How after I've submitted my
> input for a form can I get at the jsp page's instance from within the
> servlet that's processing the form's data?

Don't go that route. Your application should not keep references to any
servlet or JSP implementation class instance; the server is responsible
for keeping track of these objects and if you interfere you may run into
all sorts of problems.

> If anybody is out there. Don't do this ... it makes it very hard to reuse
> this functionality elsewhere.

Yes, it would be better to factor out this stuff in a bean or regular
class that can be used in both servlets and JSP pages.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

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