Accessibility
 
Home > Products > UltraDev > Support > Building Common Applications
Dreamweaver UltraDev Icon Macromedia Dreamweaver UltraDev Support Center - Building Common Applications
Storing the recordset data in session variables

After you extract the owner's information from the database, you must copy the information into session variables. Once the information is stored in the session variables, it can be displayed on multiple pages without needing to create a new recordset every time you open one of the pages.

In JSP, you store information in session variables using the following statement:

session.setAttribute("variable_name", value);

Your five session variables will be called sfname, slname, shrs, smodel, and sphoto. You prefix each variable with the letter "s" to identify them as session variables and prevent possible name collisions with other variables in your code.

The value of each variable is provided by a column in the recordset. In JSP, you extract the value of a recordset column using the following expression:

recordset_name.getObject("column_name")

Here is the code storing the recordset data into the session variables:

<%
session.setAttribute("sfname", rsOwner.getObject("FNAME"));
session.setAttribute("slname", rsOwner.getObject("LNAME"));
session.setAttribute("shrs", rsOwner.getObject("OCCUPIED_HRS"));
session.setAttribute("smodel", rsOwner.getObject("MODEL"));
session.setAttribute("sphoto", rsOwner.getObject("PHOTO"));
%>

You insert this code after the code block that defines the recordset. In UltraDev 4, a JSP recordset block ends with the following lines:

After adding comments and copying the recordset information into the session variables, the page's code looks as follows:

The code copies the value of the recordset's FNAME column into the sfname session variable, the LNAME column into the slname session variable, and so on.

To Table of Contents Back to Previous document Forward to next document