--- "Yee, Richard K,,DMDCWEST" <[EMAIL PROTECTED]> wrote: > Jan, > If you are new to Java and servlet programming, you should try and avoid > using global variables. As David said, the servlet container typically > starts a new thread to service each request. You really shouldn't need > to > start yet another thread inside your code. You should also avoid using > class > instance variables inside your servlet class unless you know what you > are > doing. If you want to "access Request/Response-Object without to pass > them > as parameter to each method I need to access them.", then write a > separate > class that has an HttpRequest and HttpResponse as member variables and > set > these values in the class constructor. Then have the methods inside the > class access/manipulate them.
I wouldn't do this because it implies that HttpServletRequest and HttpServletResponse are "normal" objects. They can't be stored in a session because they're not Serializable and they're only valid for one request. Storing them in an object that's discarded and recreated on every request might work but isn't very useful. David > But you should not include business logic > in > this approach as you will be tying it to the presentation (via HTTP > protocol) of your site. > > Regards, > > Richard > > > -----Original Message----- > From: Jan Zimmek [mailto:[EMAIL PROTECTED] > Sent: Monday, August 18, 2003 3:11 PM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: Re: [OT] Question about Servlets & Threads > > > Hi, > > thanks for your answer. But I think you misunderstand my intention a > little. > > Have you links to resources dealing with complex threading issues ? > > greets > Jan Zimmek > > ----- Original Message ----- > From: "David Graham" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Sent: Tuesday, August 19, 2003 12:02 AM > Subject: Re: [OT] Question about Servlets & Threads > > > > Global variables are stored in the ServletContext. You need to pass > > the request and response objects to each method or you will have > > complex threading issues to deal with. > > > > David > > > > --- Jan Zimmek <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > I know, but I want to have a similar behavior like "global > > > variables" to access Request/Response-Object without to pass them as > > > > parameter to each method I need to access them. > > > > > > Does this mailing support attachments ? Else my problem could be a > > > bit confusing. > > > > > > greets > > > Jan Zimmek > > > > > > ----- Original Message ----- > > > From: "David Graham" <[EMAIL PROTECTED]> > > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > > Sent: Monday, August 18, 2003 11:42 PM > > > Subject: Re: [OT] Question about Servlets & Threads > > > > > > > > > > --- Jan Zimmek <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > > > > > > I know this is a struts-related list, but it would be great if > > > > > some > > > of > > > > > the servlet-experts could answer my question anyway. > > > > > > > > > > First of all I have to say "I love JAVA" and will never go back > > > > > to > > > PHP > > > > > (i have started with). > > > > > > > > > > But I like the global variables in PHP like ($_GET, $_POST, > > > $_SERVER, > > > > > ....) so i tried to simulate this. > > > > > > > > > > I am doing this by merging a servlets doGet / doPost method to a > > > single > > > > > method called "process". > > > > > > > > > > This method will create foreach incoming request a new > > > Thread-Subclass > > > > > which is responsible for processing this request > > > > > (HttpServletRequest > > > and > > > > > HttpServletResponse will be referenced by according attributes > > > > > in > > > the > > > > > thread-subclass). After processing this thread will be released. > > > > > > > > You don't need to code threads in a Servlet because the container > > > > is already multi-threaded. Multiple threads will be running > > > > through your Servlet at once. > > > > > > > > David > > > > > > > > > > > > > > The thread will invoke something similar like a Action in > > > > > Struts. > > > > > > > > > > BUT NOW TO MY PROBLEM ;-) > > > > > > > > > > I have a class called "Globals" which uses the > > > "Thread.currentThread()" > > > > > method to obtain the thread responsible for this request. As > > > described > > > > > above the Request/Response-Object of this request are referenced > > > > > > by > > > the > > > > > thread and are accessible by "getter"-method. > > > > > > > > > > Can I know be sure that the Request/Response-Object is always > > > > > the it should be or can there be any inconsistency ? > > > > > > > > > > I have attached some source-files and would be very great if > > > > > some of > > > you > > > > > could explain me if anything would work or if I am running in > > > > > trap > > > :-? > > > > > > > > > > greetz > > > > > Jan Zimmek> > > > > ------------------------------------------------------------------ > > > > --- > > > > > To unsubscribe, e-mail: > > > > > [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > __________________________________ > > > > Do you Yahoo!? > > > > Yahoo! SiteBuilder - Free, easy-to-use web site design software > > > > http://sitebuilder.yahoo.com > > > > > > > > ------------------------------------------------------------------ > > > > --- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! SiteBuilder - Free, easy-to-use web site design software > > http://sitebuilder.yahoo.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]