Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/acme/gui/presObjs/TestPO1.java


1   /*
2    * Enhydra Java Application Server Project
3    * 
4    * The contents of this file are subject to the Enhydra Public License
5    * Version 1.1 (the "License"); you may not use this file except in
6    * compliance with the License. You may obtain a copy of the License on
7    * the Enhydra web site ( http://www.enhydra.org/ ).
8    * 
9    * Software distributed under the License is distributed on an "AS IS"
10   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
11   * the License for the specific terms governing rights and limitations
12   * under the License.
13   * 
14   * The Initial Developer of the Enhydra Application Server is Lutris
15   * Technologies, Inc. The Enhydra Application Server and portions created
16   * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17   * All Rights Reserved.
18   * 
19   * Contributor(s):
20   * 
21   * $Id: TestPO1.java,v 1.11.10.1 2000/10/19 17:59:06 jasona Exp $
22   */
23  
24  
25  
26  
27  /*
28   * Test presentation object #1.
29   */
30  package com.acme.gui.presObjs;
31  
32  import com.lutris.util.*;
33  import com.lutris.appserver.server.session.*;
34  import com.lutris.appserver.server.httpPresentation.*;
35  
36  public class TestPO1 implements HttpPresentation {
37      private static final String html1 = "<TITLE>Harmony Presentaion Object: TestPO1</TITLE>\n" +
38          "<H1>Hello, World</H1>\n" +
39          "Brought to you by the Harmony presentation object!\n";
40  
41      public void run(HttpPresentationComms comms) throws Exception {
42          comms.response.setContentType("text/html");
43  
44          comms.response.setStatus(HttpPresentationResponse.SC_OK, "Good job");
45  
46          HttpPresentationOutputStream out = comms.response.getOutputStream();
47          out.print(html1);
48          HttpDebug.displayComms(comms);
49  
50          
51          out.println("<CENTER>");
52          out.println("<H2>Auto Session Creation Check</H2>");
53          if (comms.session == null) {
54              out.print("*** No session object exists ***");
55          } else {
56              SessionData sessionData = comms.session.getSessionData();
57              Integer cntr = (Integer)sessionData.get("TestPO1.counter");
58              if (cntr == null) {
59                  out.print("First access to this page for this session<p>");
60                  sessionData.set("TestPO1.counter", new Integer(1));
61              } else {
62                  cntr = new Integer(cntr.intValue()+1);
63                  out.print("Access " + cntr + " to this page for this session<p>");
64                  sessionData.set("TestPO1.counter", cntr);
65              }
66          }
67          out.println("</CENTER>");
68      }
69  }