Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jspInit() method  RSS feed

 
Ulvi Cetin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is jspInit() method of a JSP equivalent of the init(ServletConfig) method of a servlet? Does is execute only once when the JSP is initialized?
I want to initialize a database connection pooling in my JSPs and wondering if this is a good place to do this.
Thx.
Ulvi.
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jspInit() method is on the JspPage interface that must be implemented by servlet classes generated from JSP pages. These servlet classes are automatcically generated by the JSP Compiler on the Application Server so (AFAIK) you don't really have much controller over what gets placed in this method.
It sounds like you are trying to put too much logic and code into the JSP page. I would probably use another method to create you connection pool, maybe a servlet that is loaded on startup that then invokes a method on a class in the business tier that actually creates and manages the connection pool.
HTH
Andy
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!