Girish Haran wrote:

> I apologize if people are getting this posting a second time. My first
> attempt appears to have failed on account of a bad sender's email
> address.
>
> Hello All:
>
> I'm attempting move from a pure servlet based system ( running on JWS )
> to a JSP based front end using WebLogic4.5.1 as my Web-enabled App
> server. Given several business pressures, I'm diving into this effort
> without properly understanding all the relevant issues in making this
> transition. I hope I can leverage the vast collective experience that
> this group has to offer. Here is my problem...
>
>    * My old system uses the MVC design pattern extensively. The servlets
>
>      are the controllers and every page that I serve is generated by a
>      team of models and renderers, with models encapsulating the
>      business logic and DB access and the renderers scripting HTML and
>      managing cookies and so on.
>    * Given my  need for better decoupling between the content generation
>
>      and the business logic, I decided to replace the rendering side of
>      the architecture with JSPs.

Seems like a viable choice.  One thing you might look at is seeing if you can
remodel some of the renderers as custom tags (JSP 1.1 when WebLogic supports it)
so that you can embed references to them in the JSP pages directly.

>
>    * I also decided to do away with the servlets and placed all the
>      controlling logic in the JSPs too. Maybe not  a wise choice but my
>      thinking is that this can be changed in due course.

This would not be my choice -- IMHO JSPs should be used for (V)iew and servlets
for (C)ontroller -- but you can make it work.

>
>    * The plan is to reuse my models as that is production quality code
>      that supports our current site ( www.biddersedge.com )

If the models can be represented by beans that are stored as session or request
attributes, this should be pretty easy.  Such beans can be readily shared between
JSPs and servlets by putting them in the appropriate scope (request, session, or
servlet context).

>
>    * One of things I do is to initialize DB, Search engine connection
>      pools and various other Webserver wide services **ONCE** per
>      lifetime of the Webserver in a InitServlet. The lot of services are
>
>      singleton objects. This guaranteed that all other downstream
>      servlets and objects had access to essential services to do their
>      job with a convenient calling metaphor.
>    * This idiom is not working out very well in WebLogic JSP. The app
>      server instantiates new classloaders at different points in time
>      making my static singletons disappear. So instead of just
>      instantiating the pools once and only once I seem to have to do
>      often, which obviously is unacceptable. To help me continue my
>      development, I created an init.jsp file that I include at the top
>      of all my top level JSP files.

You should look at storing things like connection pools and other service objects
as attributes of the servlet context, rather than using singletons.  That way, you
should be isolated from class loader issues.  It may also be necessary to load the
classes for these types of service objects from the system class path instead of
the application class path, but the details here are very specific to each server
environment.

For initialization, it is still something of a pain that there is no global
"application start" and "application stop" events in the servlet API.  I get
around this by using an initialization servlet like you do -- initialize the
resources in the init() method and finalize them in the destroy() method.  As long
as the servlet container does not throw out your initialization servlet (perhaps
because no one is calling it), this works fine.  If the server does this, you
might be better off moving the finalization stuff to a particular servlet that you
explicitly call only when you are going to shut down the server.

>
>    * This init.jsp has a synchronized static flag that keep track of the
>
>      "init" state of the JSP files and reinitialized the pool if
>      necessary. While this help me continue my development, I have to
>      come up with a better solution.
>    * The old InitServlet I used to use, apparently gets loaded with a
>      different ClassLoader , and doesn't work for my JSP files. It,
>      however, works fine for the other servlets.
>
> What are my options here? Is there a design pattern that you know of
> that will work in this situation? I have WebLogic guys also working on
> this, but am interested in hearing from you.
>
> Thanks
> Girish Haran
> Member of Tech Staff
> Bidder's Edge Inc.
>

Craig McClanahan

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

Reply via email to