On Mon, 18 Aug 2003, Jan Zimmek wrote: > Date: Mon, 18 Aug 2003 23:47:49 +0200 > From: Jan Zimmek <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > Subject: Re: [OT] Question about Servlets & Threads > > 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. >
One option to consider is to store the current request and response objects into a static variable of type java.lang.ThreadLocal (perhaps in a Filter, if you're using Servlet 2.3, or a customized RequestProcessor implementation that does this in its process() method before executing the standard processing). It's fair to warn you, though, that object oriented purists will frown on anything like this, because static variables (similar to globals in PHP) are the root of all sorts of program bugs :-). Explicitly passing things around creates *much* safer code. > Does this mailing support attachments ? Else my problem could be a bit > confusing. > > greets > Jan Zimmek Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]