|
 |
asp_databases thread: application and session objects
Message #1 by Rowenaperks@d... on Mon, 12 Jun 2000 9:47:53
|
|
-----Original Message-----
From: George Wu [mailto:GeorgeW@j...]
Sent: 08 June 2000 19:21
To: Rowena
Subject: RE: a question about your book "ASP databases"
Thanks for you help. I got good answers. But I have more questions.
(1) I am always confused by application and session objects. Could you
tell
me their differences?
(2) Do you know how to set a focus for a particular input field in a ASP
page?
Thank you very much.
George
Message #2 by "werner teunissen" <werner@t...> on Mon, 12 Jun 2000 11:21:47 +0200
|
|
The difference between Session Variables and Application Variables is that
the Application variable stays valid in the memmory as long as there are
sessions open. The session variable is only valid for a particulair session
and ends when the session is ended (either by a session.abandon or because
the session has timed out)
And to set the focus for a particulair input field you can use some
J(ava)Script.
like this :
<html>
<head><head>
<SCRIPT Language="JavaScript">
<!-- '//where frmName = the Name of the form wich contains the field that
you want to give the focus
'//and where fldName= the name of the Field that you want to give
the focus
'// the ' before the // is set because otherwise outlook thinks its
a reference to a file and makes it : file//....
'//so remove the " ' " and cut and past the code in a new text file,
give it the extension htm/html and try it
function body_onload()
{
document.frmName.fldName2.focus()
}
-->
</SCRIPT>
<BODY bgcolor='color' onload=body_onload()>
<Form ACTION="Action.asp" Name = "frmName" METHOD="Post">
<INPUT Type="text" Name=fldName><BR>
<INPUT Type="text" Name=fldName2>
</FORM>
</BODY>
</HTML>
in this example the second field gets the focus when the page loads, you can
adjust this to every situation you want..
good luck
werner
----- Original Message -----
From: <Rowenaperks@d...>
To: "ASP Databases" <asp_databases@p...>
Sent: June 12, 2000 9:47 AM
Subject: [asp_databases] application and session objects
> -----Original Message-----
> From: George Wu [mailto:GeorgeW@j...]
> Sent: 08 June 2000 19:21
> To: Rowena
> Subject: RE: a question about your book "ASP databases"
>
>
> Thanks for you help. I got good answers. But I have more questions.
> (1) I am always confused by application and session objects. Could you
> tell
> me their differences?
> (2) Do you know how to set a focus for a particular input field in a ASP
> page?
>
> Thank you very much.
>
> George
>
> ---
> Wrox Professional Wireless Developer Conference, Amsterdam, July 10-12.
Covering application of WAP, XML, ASP, Java and C++ to wireless computing,
choose from 40+ technical sessions delivered by industry experts:
http://www.wroxconferences.com/ConferenceHome.asp?ConfID=9
> ---
> You are currently subscribed to asp_databases
$subst('Email.Unsub')
Message #3 by Kevin_Riggs@p... on Mon, 12 Jun 2000 08:40:04 -0400
|
|
Application variables are stored in memory on the server and are available for
ALL sessions to access. If you have a global variable you want all sessions to
instantiate/use, you could set it in the Application. Application variables are
only reset on starting/restarting the web service.
Session variables are stored on the client machine. They are "invisible"
cookies. Application variables will not work if the client machine does not
accept cookies. Examples of session variables are Username, E-mail address, IP
address, etc.
Note:
When working in a multi-server environment (like a web-farm), Application
variables become tricky, Session variables don't. Application variables work if
you set all the servers so that they startup with the same application
variables. Session variables won't work because the Session object is tied to a
client/server connection. If the client browser starts a Session with server
one and gets moved to server two or three, the SessionID is invalid and the
information that was stored in the Session variable is released by the client as
though the user had lost TCP/IP connectivity. If you have a clustered server
that has semi-dynamic servers (ie.- Requests get directed to the least loaded
server on the first request and subsequent requests remain on that server for
the duration of the interaction barring timeouts), then you can use Session
objects to converse with your clients.
KD
Message #4 by "Ken Schaefer" <ken.s@a...> on Tue, 13 Jun 2000 19:49:24 +1000
|
|
> Application variables are stored in memory on the server and are available
for
> ALL sessions to access. If you have a global variable you want all
sessions to
> instantiate/use, you could set it in the Application. Application
variables are
> only reset on starting/restarting the web service.
>
> Session variables are stored on the client machine. They are "invisible"
> cookies. Application variables will not work if the client machine does
not
> accept cookies. Examples of session variables are Username, E-mail
address, IP
> address, etc.
There are a number of small errors in the above:
a) Application variables will work regardless of cookie support by the
client - Application variables do not require cookies.
b) Application variables are initialised on the first request to the web
application by a client - they are *not* created when the web server is
started. They are destroyed when the last session for that application ends.
Why is this signifigant? Well, you can't use application variables to track
when the web server stops and starts for example.
c) Session variables are not written to invisible cookies on the client.
Session variables are stored in the server's memory, and a sessionID is
assigned to each group of variables (ie one sessionID per user). The
sessionID is written to a cookie and sent to the user's browser. The browser
returns the cookie to the server on each page request, and the server
retrieves the appropriate session variables by matching the sessionID in the
cookie with the variables associated with that sessionID stored in memory.
You can't see this cookie, because it is a session cookie, which is stored
in the browser's memory as well, and is destroyed when you close the
browser.
Cheers
Ken
|
|
 |