tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <Wendy.Sm...@asu.edu>
Subject RE: servlets
Date Tue, 28 Jan 2003 21:53:18 GMT
> Well, the short answer is that I need instance variable values from a
> servlet (in this case, data from ServletConfig). I could certainly make
> my classes ask for the servlet instance as a method parameter, but this
> just looks so ugly to my perfectionist eyes :-)

If I've got it right, ServletConfig is where you pull out parameters that
you set in web.xml.  Those are fixed, they're just Strings, so why is it a
big deal if the values are shared among requests?  There's no prohibition
against instance variables in Servlets, you just have to be aware that there
may be multiple threads and that will share the same variables.  So no, you
don't want to set things like 'userName' as servlet instance variables.

Can you explain what problem you're trying to solve?  In order to help, we
need to know *why* you think you need a Singleton Servlet.

Perhaps the info you're storing at the Servlet level would be more
appropriately stored in application scope (ServletContext) instead??

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message