to the main page about the tutorial  INTERACTIVE WEB SERVICES WITH JAVA back up next

Code Gaps

JWIG can emulate the JSP style with embedded code using code gaps:

import dk.brics.jwig.runtime.*;

public class Today extends Service {
  int counter = 0;

  synchronized int next() { return ++counter; }

  public class View extends Page {
    public void main() {
      exit [[ <html><head><title>JWIG</title></head><body>
              Today is <{ return new Date(); }>
              <p/>
              You are visitor number <{ return next(); }>
              </body></html> ]];
    }
  }
}

back COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next