<!-- Enhydra Java Application Server Copyright 1997-1999 Lutris Technologies, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes Enhydra software developed by Lutris Technologies, Inc. and its contributors. 4. Neither the name of Lutris Technologies nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY LUTRIS TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUTRIS TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <JDDI JAVAIMPORT> import com.lutris.appserver.server.session.*; import com.lutris.http.*; import demoApp.presentation.utilities.*; </JDDI> <JDDI INCLUDE="../jinc/Setup.jinc"></JDDI> <JDDI JAVADEF> String key = "session.accessCount"; public void SessionAccess(JoltPage page) throws Exception { /**** * Checks for session key and sets up a counter at 1 if it's our * first time here. Updates counter on subsequent returns here ****/ SessionUtils.authenticate(page); PageUtils.handlePreviousForm(page.session, page.data); SessionData sessionData; sessionData = page.session.getSessionData(); if (!sessionData.containsKey(key)) { page.data.set("haveKey", "false"); sessionData.set(key, new Integer("1")); } else { page.data.set("haveKey", "true"); page.data.set("accessCount",sessionData.get("session.accessCount")); int count = ((Integer)sessionData.get(key)).intValue(); sessionData.set(key, new Integer(count + 1)); } } </JDDI> <JDDI JAVACALL=SessionAccess></JDDI> <HTML> <HEAD> <TITLE>JDDI HTML Example: Session Data</TITLE> </HEAD> <JDDI INCLUDE="../jinc/Header.jinc"></JDDI> <BODY> <CENTER> <B><FONT FACE="Arial,Helvetica" SIZE=+3> Session Data </FONT></B> </CENTER> </BODY> <JDDI INCLUDE="../jinc/Buttons.jinc"></JDDI> <JDDI INCLUDE="../jinc/Home.jinc"></JDDI> <BODY> <BR> <CENTER> <TABLE COLS=1 WIDTH="60%"> <TR> <TD> <FONT FACE="Arial,Helvetica" SIZE=+1> This page displays session persistent data. Reload this page (via your browser's "reload" button), and witness the magic of session persistent data. </FONT> </TD> </TR> </TABLE> </CENTER> <BR> <JDDI HTML IFEQ FIELD=cgiArgs.help VALUE="on"> <CENTER> <TABLE COLS=1 WIDTH="40%" > <TR> <TD> <FONT FACE="Arial,Helvetica" COLOR=red> The session "count" displayed below is kept track of via embedded Java code that maintains a local integer counter and updates it every time the page is reloaded. The value of this counter is stored in the active session, which causes it to persist across reloads or returns to this page. You can check the source for this file (via the "Source" button above) for the details on how this is done. </FONT> <CENTER><IMG SRC="../media/arrow.gif" BORDER=0 ANCHOR=BOTTOM></CENTER> </TD> </TR> </TABLE> </CENTER> </JDDI> <JDDI HTML IFEQ FIELD=haveKey VALUE="true"> <CENTER> <TABLE COLS=1 WIDTH="60%"> <TR> <TD> <FONT FACE="Arial,Helvetica"> During this session, you have accessed this page <B><FONT COLOR=red>(@accessCount@)</FONT></B> times. </FONT> </TD> </TR> </TABLE> </CENTER </JDDI> <BR> <JDDI INCLUDE="../jinc/VerboseDebug.jinc"></JDDI> </BODY> </HTML>