NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
INTERACTIVE WEB SERVICES WITH JAVA |
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):
Name | Lines | Templates | Shows | Time |
Chat | 80 | 4 | 3 | 9.7 |
Guess | 94 | 8 | 7 | 11.1 |
Calendar | 133 | 6 | 2 | 10.0 |
Memory | 167 | 9 | 6 | 15.1 |
TempMan | 238 | 13 | 3 | 11.0 |
WebBoard | 766 | 32 | 24 | 13.5 |
Bachelor | 1,078 | 88 | 14 | 131.3 |
Jaoo | 3,923 | 198 | 9 | 39.9 |
COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |