Rajendra Mishra wrote:

> By this, do you mean that the data is persistent across sessions for a
> client? For exp, I have a user who selects a site nbr. Depending upon this
> selection, I return the appropriate database connection to all the servlets
> which requests it. Since it is not cecessary for the user toselect the site
> agian, I need to store this site as a client/machine/user (?) specific
> attribute. Ths user is not required to select the site again(he can change
> it though.).

Data stored in the servlet context is persistent across all sessions for all
users (i.e. it stores "global variables" for the application), but there are no
guarantees about persistence across server restarts.  This is not the right
place to store things that should really be permanent.

>
> Given this scenario, would a ServletContext work or I would have to write an
> extrnal file/hashtable where a list of users with their current preferences
> would be stored?
>

The approach I would suggest for this kind of thing is to store the preferences
for each user wherever you store their username and password (in a database, in
a disk file, or whatever).  Then, when the user logs on, read the appropriate
data and create a bean that represents the user's preferences in their session
variables.  That way, you only need to read the user's stuff once when each
time they log on.

If the user is allowed to change their preferences, this bean could have a
store() method or something like that, to store the updated preferences back to
permanent storage.

>
> Thanks.
> raaj.
>

Craig McClanahan


>
> >     note: some of the above is servlet 2.2 specific and may not
> >         directly address servlet 2.1 or lesser implemenations. in
> >         this area the servlet 2.2 spec made the data accessors more
> >         consistent accross the api.
> >
> > you can store data in other more exotic containers (eg database,
> > singleton, ejb) but i have a feeling even if you do this some
> > subset of the associated data will be stored in one or more
> > of the above mentioned javax.servlet.* constructs.
> >
> > hope this helps,
> >
> > - james
> >
> >
> >
> > Ted Neward wrote:
> >
> > > I can certainly answer the second one, but I'll defer the first one to
> > > others more comfortable with the Servlet spec than I.
> > >
> > > Using stored procs does for you what using methods to access private
> data
> > > does within Java classes: it helps encapsulate the details of the
> > > underlying database schema. By using stored procs to obtain and/or
> > > manipulate the entities within the database, your DBAs can shuffle the
> > > schema around as necessary (to optimize for size, speed, certain
> queries,
> > > whatever is necessary) without having to recompile SQL code. (Other
> > > approaches to achieve this same effect include placing the SQL within
> text
> > > files that the application simply reads and executes, but then if the
> SQL
> > > changes, all of those "SQL properties" files require updating--not a
> > > simple chore.)
> > >
> > > Since you're using Oracle, you may as well make use of Oracle's rather
> > > powerful PL/SQL language and syntax. Note that you're still using
> > > JDBC--you're just using it to make stored proc calls, instead of
> directly
> > > executing SQL statements.
> > >
> > > Ted Neward
> > > http://www.javageeks.com/~tneward
> > >
> > > On Thu, 11 Nov 1999, Lalith Jayaweera wrote:
> > >
> > > > Hi
> > > >  I need Ur help to sort it out following twoe two questions .
> > > >
> > > > (1) How can we pass a variable which is used in one servlet to another
> > > > servlet which will be used later.What am currently doing is creating a
> > > > session object and putting the value and getting the value back when
> > > > necessary.Is there any otherway that I can use instead of this one.
> > > >
> > > > (2)Rather than using jdbc..  for database access(writing sqlcodes well
> > > > within the servlet) is there any advantage if I can use stored
> > > > procedures.(am using
> > > > oracle as my database server);
> > > >
> > > >
> > > > Thanks in Advance
> > > > lalith
> > > >
> > > >
> ___________________________________________________________________________
> > > > 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
> > > >
> > >
> > >
> ___________________________________________________________________________
> > > 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
> >
> >
> ___________________________________________________________________________
> > 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
> >
>
> ___________________________________________________________________________
> 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

___________________________________________________________________________
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