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

Catching Errors

If we introduce an error by forgetting the name attribute:
import dk.brics.jwig.runtime.*;

public class Greetings extends Service {
  String greeting = null;

  public class Welcome extends Session {
    XML cover = [[ <html>
                   <head><title>Welcome</title></head>
                   <body bgcolor=[color]>
                    <{ if (greeting==null)
                         return [[ <em>Hello World!</em> ]];
                       else 
                         return [[ <b><[g]></b> ]] <[g=greeting];
                    }>                    
                    <[contents]>
                  </body>
                 </html> ]];
  
    XML getinput = [[ <form>Enter today's greeting: 
                         <input type="text" name="salutation"/>
                         <input type="submit"/>
                      </form> ]];
 
    XML message = [[ Welcome to <[what]>. ]];

    public void main() {
      XML h = cover<[color="white",contents=message];
      if (greeting==null) {
        show cover<[color="red",contents=getinput];
        greeting = receive salutation;
      }
      exit h<[what=[[<b>BRICS</b>]]];
    }
  }
}

then the following error message is produced:
*** Field `salutation' is never available on line 30
*** Invalid XHTML at line 29
--- element 'input': requirement not satisfied:
<or>
 <attribute name="type">
  <union>
   <string value="submit" />
   <string value="reset" />
  </union>
 </attribute>
 <attribute name="name" />
</or>
2 problems encountered.

This is fast enough to run in practice (time in seconds):
NameLinesTemplatesShowsTime
Chat80439.7
Guess948711.1
Calendar1336210.0
Memory167 9615.1
TempMan23813311.0
WebBoard766322413.5
Bachelor 1,0788814131.3
Jaoo3,923198939.9

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