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 PowerFreebie extends Service { public class HowMany extends Session { static final int MAX = 5; XML templateAsk = [[ <html><body><form> How many free T-shirts do you want? <input name="amount" type="text"/> <input name="continue" type="submit"/> </form></body></html> ]]; XML templateReply = [[ <html><body> You will receive <[amount]> k00l T-shirts any day now... </body></html> ]]; XML format = [[ <powerforms> <constraint field="amount"> <regexp pattern=[pattern]/> </constraint> </powerforms> ]]; public void main() { show templateAsk powerforms format<[pattern="<1-"+MAX+">"]; int amount = Integer.parseInt(receive amount); exit templateReply<[amount=amount]; } } } |
Notable points:
COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |