You almost never put anything in the servlet; the servlet is just a tiny
stub, a bridge between the servlet API and all things Tapestry.
Operations such as obtaining database connections are specific to your
application, but not specific to any particular user, which is to say the
operation is stateless. In the Tapestry world, the best place for such as
thing is in your engine.
public class MyEngine extends SimpleEngine
{
public Connection getDatabaseConnection() ...
}
public class MyPage extends BasePage
{
public void someMethod(...)
{
MyEngine engine = (MyEngine)getEngine();
Connection = engine.getDatabaseConnection();
...
}
----- Original Message -----
From: "Alex Reid" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 20, 2002 12:15 PM
Subject: [Tapestry-developer] best way to get a db connection
> Okay, my apologies if this has been answered before. It's quite a basic
> question!
>
> What's the 'best' way to get a java.sql.Connection within a Tapestry
> application. For instance in a Struts application I have a
> DbConnectionBroker instance referenced in the application context. Any
> servlet can access it by pulling it out of that context.
>
> I am not sure how this would work in Tapestry ... any ideas?
>
> Do I subclass ApplicationServlet and add getConnection() type methods? How
> would my BasePage-derived 'pages' access this?
>
> Thanks,
> Alex
>
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _______________________________________________
> Tapestry-developer mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/tapestry-developer
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer