Mike thanks for the feedback, but is this the practical solution? For
example, I am using a connection pool, the init is only done once, the
bean does the processing, after the processing it done (that is the
beans "set" their properties) the results are forwarded to another jsp
for viewing, so where do I release my connection back into the pool?

TIA

Tom K.




-----Original Message-----
From: Mike Curwen [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 22, 2004 1:31 PM
To: 'Tomcat Users List'
Subject: RE: Database connection going from servlet to a bean

There is a jspInit() method in a JSP that you can 'override' by doing:

<%!

public void jspInit() {


}

%>

So the answer for 'how' is; "the same way"


> -----Original Message-----
> From: Tom K [mailto:[EMAIL PROTECTED] 
> Sent: Monday, March 22, 2004 12:58 PM
> To: [EMAIL PROTECTED]
> Subject: Database connection going from servlet to a bean
> 
> 
> I am going from a html-->servlet-->output to a 
> jsp-->javabean-->jsp configuration.
>  
> In my servlet I connect via JNDI like this:
> public void init(ServletConfig config) throws ServletException{
>     super.init(config);
>       try{
>           Context env = (Context) new 
> InitialContext().lookup("java:comp/env");
>           pool = (DataSource) env.lookup("jdbc/app1");
>  
>           if (pool == null)
>             throw new ServletException("`jdbc/app1' is an 
> unknown DataSource");
>       }catch (NamingException e) {
>         throw new ServletException(e);
>       }
>  
> How would I connect using a JSP? Or would this be done in the 
> javabean?
>  
> TIA
>  
> Tom K.
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003
>  
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to