Raj wrote:

> Hi all,
> I have few doubts to be clarified in designing our Web framework. I will
> appreciate, if you can provide me the guidance in the following issues
> regarding Singleton. ...

Hi Raj,

I also want to know how to use Singleton_type_class in Servlet :-)
but now I am not clear :-) , I just guess the following problems are
very Similar :-)

*    cocurrent programming in Servlet
      *   with SingleThreadModel
      *   with field to lock the code
      *   with "synchronized method" to lock the code
      *   "dynamic data" for every "client requesting"

*   how to use Singleton_type_class in Servlet
     *  where to instantiate it
     *  when to instantiate it

I think the reason is because that now I don't know some "basic
concepts" of how a special servlet engine works :-) :-)
The following are my guessing and questions  :-)

*   I think we can instantiate a Singleton_type_class in :
     [Initialization] or  [static/non-static Initialization block]
     please read a new book :-) -- "The Java Programming
     Language Third Edition" ISBN:0-201-70433-1  , from
     P43   :-)

*   "init method" --  ?   :-)

*   I find I can not write any [class constructor] in my Servlet
    class if I use Jsdk2.1(windows), otherwise I will get a
    java.lang.InstantiationException :-) ,  is it because
    Servlet is one kind of "let" -- like applet ?   :-)

* now I guess perhaps the better way for "sync/lock code"
   is "implements SingleThreadModel" if we don't know
   the "detail" of Servlet engine, and I guess perhaps all
   the Servlet engine  will support this way :-)
        * and I find the following in the link --
           http://forum.java.sun.com/read/16788242/qAoe_a1EClu0AAYpf#LR
           ...
           That means: SingleThreadModel just like declare method
           service () synchronized. It's "thread safety".
           public  synchronized void service (ServletRequest req ,
           ServletResponse res) throws ServletException, IOException ;
           ...
        *  I also got the similar result from my testing --  I find the "whole
           service method" has been locked, and I guess it is "global
           locked in Servlet engine"

*But if we only want to lock part of our code in service(or doGet/doPost),
 for example, we want to make [the code for "analysing input data"]
 "multi-thread", but we want to make [the code for EJB or DB operating]
 "singe-thread",  now is the following possible?  :-)
      *   put [the code for EJB or DB operating] in another Servlet class which
          implements SingleThreadModel  - servlet_2
      *   in servlet_1, after "analysing input data", then

response.sendRedirect(response.encodeRedirectURL("/servlet/servlet_2"));


BTW, I guess perhaps Servlet is one of the "Entrance of the whole Server-side
Java world" :-)  -- it is "Jim Morrison -- the Doors :-) :-) ,  so I want to
know the
above concepts very clearly, could anybody give me direction about that?
thanks very much :-)

Thanks in advance!

Bo
Oct.16, 2000

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to