Hi Craig, List,
What I've done is create a servlet that launches with Jrun that houses my
database connection pool. I do it this way to ensure that my application
has a common supply of connections, and the servlet functionality ensures
that it launches before other apps and also allows me to get the pools
status by doing GETs to the servlet. But this means that I have to extract
the servlet from the application variable in JSP and pass it to each bean I
create, and what I'd like to do is find some way that I can do it
automatically without coding it into every JSP page.
One of my beans needs the servlet context because it is a bean that allows
the user to add and delete files from his web directory, and I need to be
able to call the getRealPath method to convert web paths to real paths,
which requires the servlet context. But doing all of the file manipulation
in a bean seems to be proper separation-of-function. Is there a better way?
Richard Sand ([EMAIL PROTECTED])
http://www.vgalleries.com
-----Original Message-----
>If your bean needs to know about servlet context or session attributes
>directly, you need to pass them (either the other attributes themselves,
>or the ServletContext or HttpSession instances) directly as method
>arguments to some method of your bean that saves them for later use.
>This is a basic Java programming issue, and nothing specific to servlets
>and JSP.
>
>On the other hand, the fact that you find this necessary means you
>should really spend some time looking at your application architecture.
>Beans that need to know they are invoked by servlets are probably not as
>well factored (in the object oriented design sense) as they should be.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html