× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Source Evaluation?
  • From: "Larry Loen" <lwloen@xxxxxxxxxx>
  • Date: Fri, 9 Feb 2001 12:03:15 -0600
  • Importance: Normal


Paul Clapham wrote:

>But in my (limited) experience, I've found that
>most of my servlets don't require an init() method.

Well, strictly speaking, you are correct.  However,
this is an interesting topic.  Either a static class initializer or the
init
method is a good place to stick read-only kinds of objects, especially
those that are fairly expensive to construct.

As I understand the servlet rules, you can't really use regular "instance"
variables on grounds that architecturally, multiple threads can
simultaneously
use the same servlet object.  This means modification raises thread safety
issues.  However, you can put instance variables in them that are
what Java calls "immutable" -- don't change after they are constructed.
These are thread safe by design and definition.

Still, an init method can in the end include a lot of stuff, the kind
of stuff that starts out in .ini files and are configuration specific, such
as
the www.whateversystemthisis.com prefix  and like things.

I must admit, I tend to use the static class initializer because most of
this
stuff only needs to be done once and can fit in class-wide variables.  But
if I thought about it longer, I could probably find examples that made
sense for
init as well.




Larry W. Loen  -   Senior Java and AS/400 Performance Analyst
                          Dept HP4, Rochester MN


+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.