1 10 11 package com.lutris.appserver.welcome.presentation; 12 13 import com.lutris.appserver.server.httpPresentation.*; 16 import com.lutris.appserver.server.session.*; 17 import com.lutris.util.*; 18 import java.io.*; 19 import org.w3c.dom.*; 20 import org.w3c.dom.html.*; 21 22 25 public class Welcome implements HttpPresentation { 26 30 private static int counter = 0; 31 32 35 public void setCounters(Session session, 36 WelcomeHTML htmlObj) 37 throws KeywordValueException { 38 43 counter++; 44 htmlObj.setTextTotalHits(Integer.toString(counter)); 45 46 53 SessionData sessionData = session.getSessionData(); 54 String userCounterString = sessionData.getString("counter"); 55 int userCounter = 0; 56 if (userCounterString != null) { 57 userCounter = Integer.parseInt(userCounterString); 58 } 59 userCounter++; 60 userCounterString = Integer.toString(userCounter); 61 sessionData.set("counter", userCounterString); 62 63 htmlObj.setTextUserHits(userCounterString); 64 } 65 66 69 public void run(HttpPresentationComms comms) 70 throws HttpPresentationException { 71 try { 72 WelcomeHTML htmlObj 73 = (WelcomeHTML)comms.xmlcFactory.create(WelcomeHTML.class); 74 setCounters(comms.session, htmlObj); 75 comms.response.writeHTML(htmlObj); 76 } catch (KeywordValueException except) { 77 throw new HttpPresentationException(except); 78 } 79 } 80 } 81 | Popular Tags |