GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Languages for Interactive Web Services Claus Brabrand [ Joint work with Anders Møller, Michael Schwartzbach, BRICS, Denmark ] Compose Research Group INRIA/LaBRI, University of Bordeaux I
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Abstract Increasingly, HTML/XML documents on the Web are dynamically generated by embedded server-side scripting languages, such as PHP, ASP, and JSP. However, this has five serious limitations: it forces linear document construction, intermixes designer/programmer aspects, yields implicit control-flow, prevents static XML validation, and precludes caching. This talk presents a flexible, safe, and efficient language for dynamically generating XML documents that solves the above problems. We also show how to augment XHTML documents with form-field validation through declarative specifications. More information: The Project:
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Program Family ”Web servers on which clients can initiate sessions that involve several exchanges of information that involve several exchanges of information mediated by HTML forms”. mediated by HTML forms”. server client Internet Interactive (Form-Based) Web Services:
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family Java Servlet
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 A Program from the Program Family WebService CLIENT INTERNET SERVER
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family session management Java Servlet
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family state management Java Servlet
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family document construction Java Servlet
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family Java Servlet session management state management document construction
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } A Program from the Program Family session management state management document construction Java Servlet
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 The Language/System A high-level domain-specific programming language for developing interactive Web services. A high-level domain-specific programming language for developing interactive Web services. HTML CGI Scripts JavaScript HTTP Auth. Java Applets Complete Service Specification Complete Service Specification
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 = a Collection of Domain Specific Languages = a Collection of Domain Specific Languages C-like core language with C-like core language with Session-based runtime system Session-based runtime system Dynamic documents Dynamic documents Form-field validation Form-field validation Relational database Relational database Concurrency control Concurrency control Semantic security Semantic security Cryptographic security Cryptographic security Syntactic-level macros Syntactic-level macros
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 = a Collection of Domain Specific Languages = a Collection of Domain Specific Languages C-like core language with C-like core language with Session-based runtime system Session-based runtime system Dynamic documents Dynamic documents Form-field validation Form-field validation Relational database Relational database Concurrency control Concurrency control Semantic security Semantic security Cryptographic security Cryptographic security Syntactic-level macros Syntactic-level macros
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Implementation Approaches Traditionally 2 approaches: Traditionally 2 approaches: –Script-centered: Perl/CGI, Java Servlets, … Perl/CGI, Java Servlets, … –Page-centered: ASP, PHP, JSP,... ASP, PHP, JSP,...
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService request
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER WebService computereply
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService HTML
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService submit
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e WebService computereply
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered: Perl/CGI, Servlets,... e CLIENT INTERNET SERVER e e WebService HTML
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e Page-Centered: PHP, ASP, JSP,... CLIENT INTERNET SERVER WebService
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Page-Centered Increased level of abstraction: Increased level of abstraction: CGI protocol details abstracted away CGI protocol details abstracted away Easy to add dynamics to static pages: Easy to add dynamics to static pages: Scalability: Scalability: Specialized Web server Specialized Web server “Service code embedded in tags and interpreted by specialized Web server” interpreted by specialized Web server” Time:
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Script-Centered vs. Page-Centered As the service complexity increases: As the service complexity increases: –Page-Centered Script-Centered A lot of HTML is generated by script elements A lot of HTML is generated by script elements Interesting duality: Interesting duality: Script-centered: Script-centered: –Default: programming, Escape: printing ( print ) Page-centered: Page-centered: –Default: printing, Escape: programming ( )
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Fundamental Drawbacks a_scriptanother_script submit WebService A service = a collection of scripts/pages! A service = a collection of scripts/pages! Implicit control-flow: Implicit control-flow: No interaction correspondence: No interaction correspondence:
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Session-Centered: Mawl and ! e CLIENT INTERNET SERVER e e Web Service show x; show y; x y submit
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Session-Centered: Mawl and ! e e Web Service show x; show y; x submit Domain specific abstration: show Domain specific abstration: show Explicit control-flow Explicit control-flow Check interaction correspondence Check interaction correspondence
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e General Purpose Manually CLIENT INTERNET SERVER WebService
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e save General Purpose Manually CLIENT INTERNET SERVER WebService
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 e e e save restore General Purpose Manually CLIENT INTERNET SERVER WebService
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 General Purpose Manually Private (to each session thread): Private (to each session thread): ServletContext context = getServletContext(); int p ((Integer) context.getAttribute("p")).intValue(); p++; context.setAttribute("p", new Integer(var));
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 General Purpose Manually Private (to each session thread): Private (to each session thread): Shared (among all session threads): Shared (among all session threads): HttpSession session = request.getSession(true); int s ((Integer) session.getValue("s")).intValue(); s++; session.setValue("s", new Integer(var)); ServletContext context = getServletContext(); int p ((Integer) context.getAttribute("p")).intValue(); p++; context.setAttribute("p", new Integer(var));
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific: shared modifier Private (to each session thread): Private (to each session thread): int p;... p++;...
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific: shared modifier Private (to each session thread): Private (to each session thread): Shared (among all session threads): Shared (among all session threads): shared int s;... s++;... int p;... p++;...
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Automatically e CLIENT INTERNET SERVER e e Web Service [ save ] [ restore ] show x; show y; x y submit
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Dynamically Generated XML: Current Problems Traditionally: Traditionally: print(...) in Perl/CGI,... print(...) in Perl/CGI,... in PHP, ASP, JSP,... in PHP, ASP, JSP,... Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Our Solution: HTML documents in Our Solution: HTML documents in Templates (1 st class, higher-order values): Templates (1 st class, higher-order values): XML fragments with named gaps: XML fragments with named gaps: Operations: Operations: plug:for document construction plug:for document construction show:for client interaction show:for client interaction [[ Hello ! Hello !]]
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Plug Plug: exp <[ id = exp ] Plug: exp <[ id = exp ]
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Plug Plug: exp <[ id = exp ] Plug: exp <[ id = exp ] Example: Example: html hello = [[ Hello ! ]]; html world = [[ World ]]; html h = hello <[what = world];...;
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show Show: show exp ; Show: show exp ; x CLIENT INTERNET SERVER e show x; submit suspend resume
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show Show: show exp ; Show: show exp ; Example: Example: x CLIENT INTERNET SERVER e show x; submit suspend resume html hello = [[ Hello ! ]]; html world = [[ World ]]; html h = hello <[what = world]; show h;
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show-Receive Show: show exp receive[v =f,... ]; Show: show exp receive[v =f,... ]; x CLIENT INTERNET SERVER e f,... submit show x receive[v=f,..];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Show-Receive Show: show exp receive[v =f,... ]; Show: show exp receive[v =f,... ]; Example: Example: string s; html input = [[ Enter Enter ]]; show input receive[s = ]; x CLIENT INTERNET SERVER e show x receive[v=f,..]; f,... submit
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: PHP/ASP/JSP List of results (e.g. “search engine”): List of results (e.g. “search engine”): One template with 10,20,30, or 40 hardwired server-side script elements: One template with 10,20,30, or 40 hardwired server-side script elements: One template with one big ”generate-all” server-side script element: script-centered One template with one big ”generate-all” server-side script element: script-centered...or... : <% for i=1 to N do {..i.. } %> {..i.. } %>
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): 1 2 : N 1 2 : N
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ” : N 1 2 : N html layout = [[ ]]; html entry = [[ ]];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ”......and one recursive function: “ f ”...and one recursive function: “ f ” html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; 1 2 : N 1 2 : N
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Flexibility: Flexibility: List of results (e.g. “search engine”): List of results (e.g. “search engine”): Two templates: “ layout ” and “ entry ”... Two templates: “ layout ” and “ entry ”......and one recursive function: “ f ”...and one recursive function: “ f ” Example usage: Example usage: html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} 1 2 : : 27 html layout = [[ ]]; html entry = [[ ]]; show f(27);
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; Flexibility: Separates Designer / Programmer Aspects
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 html f(int n) { if (n == 0) return layout; if (n == 0) return layout; return f(n-1) <[items = entry <[num = n]]; return f(n-1) <[items = entry <[num = n]];} html layout = [[ ]]; html entry = [[ ]]; html layout = [[ ]]; html entry = [[ ]]; Flexibility: Separates Designer / Programmer Aspects
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching a_scriptanother_script submit
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety (in terms of ) Show/Receive correspondence: Show/Receive correspondence: Gap presence: Gap presence: html d = [[ Enter Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis! Apply standard, data-flow analysis techniques, but with highly domain-specific lattices
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis! Conservatively approximate for all HTML variables & program points: Conservatively approximate for all HTML variables & program points: Their gaps and fields (and their kinds) all possible runtime values Their gaps and fields (and their kinds) all possible runtime values Forward data-flow analysis: Forward data-flow analysis: 1. Control-flow graph (trivial for ) 2. Finite lattice: Gap-and-Field 3. Monotone transfer functions: plug, assign,...
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Gap-and-Field Lattice GKind nogap string html error FKind text nofield checkboxradio tup(F 1 ) rel(F 1 )rel(F n ) tup(F n ).. An abstract document is: (GName GKind) x (FName FKind) An abstract document is: (GName GKind) x (FName FKind) FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]FNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtmlGNameGKindahtml ghtml nnogap
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtml FNameFKindahtml ghtml nnogap GNameGKinda g n G : GKind x GKind GKind
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKind ahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKindahtml ghtml nnogap GNameGKindanogap gnogap nhtml FNameFKindahtml ghtml nnogap GNameGKindahtml g n G : GKind x GKind GKind
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKind ahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap n G : GKind x GKind GKind
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKind ahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap nhtml G : GKind x GKind GKind
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Functions Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] FNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogapFNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogapGNameGKindanogap gnogap nhtmlGNameGKindahtml gnogap nhtml
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors gap present E 1 <[g = E 2 ] FNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Then: Check Solution Traverse solution: intercept errors Traverse solution: intercept errors gap present field present type check: v ~ text E 1 <[g = E 2 ] show E receive[v=f,... ]; FNameFKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap GNameGKindahtml ghtml nnogap FNameFKinderadio ftext ttext
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety? Show/Receive interaction correspondence: Show/Receive interaction correspondence: Gap presence: Gap presence: html d = [[ Enter Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Type Safety! Show/Receive interaction correspondence: Show/Receive interaction correspondence: Gap presence: Gap presence: html d = [[ Enter Enter ]]; show d receive[s = age]; html hello = [[ Hello ! ]]; html world = [[ World ]]; html h; h = hello <[contents = world]; *** receive.wig:5: input field ‘ ’ not received no such input field ‘age’ *** receive.wig:5: input field ‘ ’ not received no such input field ‘age’ *** plug.wig:5: no such gap ‘contents’
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Welcome” html greeting = [[ Hello, welcome to. Hello, welcome to. ]]; html cover = [[ Welcome Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; Valid HTML !?
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Static Analysis (again)! Conservatively approximate for all HTML variables & program points: Conservatively approximate for all HTML variables & program points: A summary graph all possible runtime values A summary graph all possible runtime values Forward data-flow analysis: Forward data-flow analysis: 1. Control-flow graph: (trivial for ) 2. Finite lattice: summary graphs 3. Monotone transfer functions: plug, assign,...
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” greeting who html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” greeting gpce who what html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Summary Graph ”Stranger” cover greeting gpce contentswho what html greeting =...; html cover =...; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ]
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: g g gg x 1 <[g = x 2 ] x 1 <[g = x 2 ]
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ] x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ] x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ] x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: <[g = ] x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg However, too imprecise...!
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function <[g = ] Plug: Plug: open gaps x 1 <[g = x 2 ] x 1 <[g = x 2 ] g g gg g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Monotone Transfer Function Plug: Plug: x 1 <[g = x 2 ] x 1 <[g = x 2 ] <[g = ] open gaps g g gg g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 GapTrack Analysis GapTrack data-flow analysis: GapTrack data-flow analysis: – program points compute: “Tracks the origins (templates) of open gaps” “Tracks the origins (templates) of open gaps” (g ) (g ) (g ) (g ) ’ ’ ’ ’ : GName 2 TEMPLATES <[g = ] g g gg g g gg
GPCE 2003, Erfurt Dynamic Generation of XML September 22, ; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; Now: summary graph show statements Now: summary graph show statements Then what...? Then what...? Validation? ”Stranger” cover greeting brics contentswho what
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation? a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs A summary graph describes:
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation? a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs A summary graph describes: A DTD describes (e.g. XHTML 1.0):
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation! a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs validation! A summary graph describes: A DTD describes (e.g. XHTML 1.0):
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Validation! a set of a set ofhopeful XML docs a set of a set ofhopeful XML docs a set of a set ofvalid XML docs a set of a set ofvalid XML docs validation validation! Decidable!: Summary graph traversal (parsing vs. DTD) Memoization termination Sound and complete! Decidable!: Summary graph traversal (parsing vs. DTD) Memoization termination Sound and complete!
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Compiler Validation Recipe Step-by-Step: Step-by-Step: 1. Extract control-flow graph 2. Gap-and-Field data-flow analysis 3. GapTrack data-flow analysis 4. Summary Graph data-flow analysis 5. Validation ( shows)graph analysis
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments 800MHz Pentium III / Linux Program# Lines# TemplatesTime (sec.) chat guess calendar xbiff webboard cdshop jaoo bachelor courses eatcs Many validation errors found, no spurious errors
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example Revisited html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Planting an Error html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example Revisited --- welcome.wig:13 HTML Validation: welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: contents: td plugs: contents:{welcome.wig:13} --- welcome.wig:13 HTML Validation: welcome.wig:7 warning: possible illegal subelement ‘td’ of ‘table’ template: contents: td plugs: contents:{welcome.wig:13} html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h]; html greeting = [[ Hello, welcome to. ]]; html cover = [[ Welcome ]]; html h; h = greeting <[who = ”Stranger”]; h = h GPCE ]]]; show cover <[contents = h];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation Constant: Constant: O (1) O (1) Plug: Plug: O (1) O (1) Show: Show: O (|d|) O (|d|) [[ hello ! ]] x <[g = y] show d;
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure string
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation document structure stringtemplates
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation dynamic
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation static dynamic
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation static dynamic “Transmit JavaScript recipe for client-side doc. reconstruction” “Transmit JavaScript recipe for client-side doc. reconstruction”
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Representation static dynamic “Transmit JavaScript recipe for client-side doc. reconstruction” “Transmit JavaScript recipe for client-side doc. reconstruction” “Write each template to a separate file so that it can be cached” “Write each template to a separate file so that it can be cached”
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments Size of HTML: Size of HTML: original HTML JavaScript reconstruction...all templates cached Cut to 2.6% – 25% size
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Experiments (700MHz, 28.8 Modem) Time (download+render): Time (download+render): original HTML...all templates cached 2.2x – 10x faster
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Problems? “DynDoc”: “DynDoc”: Templates with named gaps Templates with named gaps Plug and show Plug and show Problems: Problems: Forces linear document construction Forces linear document construction Intermixes programmer / designer aspects Intermixes programmer / designer aspects No interaction correspondence No interaction correspondence No static XML validation No static XML validation No common fragments caching No common fragments caching
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Enter ” html input = [[ Please enter your Please enter your ]]; html output = [[ Your is: ]]; string s; show input receive[s = ]; show output <[ = s];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Enter ” format = (\. )+”); html input = [[ Please enter your Please enter your ]]; html output = [[ Your is: ]]; string s; show input receive[s = ]; show output <[ = s];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Enter ” format = (\. )+”); html input = [[ Please enter your Please enter your ]]; html output = [[ Your is: ]]; string s; show input receive[s = ]; show output <[ = s];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Example: ”Enter ” format = (\. )+”); html input = [[ Please enter your Please enter your ]]; html output = [[ Your is: ]]; string s; showshow input receive[s = ]; show show output <[ = s];
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Form Field Validation: “PowerForms” Domain specific language: Domain specific language: uniquely for form-field validation uniquely for form-field validation Declarative specification (regexps): Declarative specification (regexps): Abstracts away operational details Abstracts away operational details PowerForms also available as stand-alone tool PowerForms also available as stand-alone tool PowerFormsPowerForms HTML JavaScript (subset) JavaScript (subset) HTML Regexps
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Form-Field Interdependency “Favorite Letter” “Favorite Letter”Favorite LetterFavorite Letter Select filtering Select filtering “NYC Office” “NYC Office”NYC OfficeNYC Office Complex interdependency Complex interdependency
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Outline Introduction (Program Family) Introduction (Program Family) Session Management Session Management State Management State Management Document Construction Document Construction Domain Specific Verifications Domain Specific Verifications Domain Specific Optimization Domain Specific Optimization Form-Field Validation Form-Field Validation Conclusion Conclusion
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Language Design and Analyses: Yield: Yield: Flexible, Safe, and Efficient Dynamic Generation of XML
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Domain Specific Language Design and Analyses: Yield: Yield: AND: AND: Non-linear document construction Non-linear document construction Separates programmer / designer aspects Separates programmer / designer aspects Guaranteed interaction correspondence Guaranteed interaction correspondence Static XML validation Static XML validation Common fragments caching Common fragments caching Flexible, Safe, and Efficient Dynamic Generation of XML
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Objective Assessments Robustness: Robustness: Session integrity Session integrity State integrity State integrity Interaction correspondence Interaction correspondence XML validity XML validity Performance Performance Well... Well... Conciseness Conciseness 1/5 code (compared to Java Servlets) 1/5 code (compared to Java Servlets)
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 public class SessionServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); HttpSession session = request.getSession(true); response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" Servlet Demo "); if (session.isNew()) { out.println(" " + "Enter your name: " + " "); session.putValue("state", "1"); } else { String state = (String) session.getValue("state"); if (state.equals("1")) { String name = (String) request.getParameter("handle"); int users = ((Integer) context.getAttribute("users")).intValue() + 1; context.setAttribute("users", new Integer(users)); session.putValue("name", name); out.println("Hello " + name + ", you are user number " + users); session.putValue("state", "2"); } else /* state.equals("2") */ { String name = (String) session.getValue("name"); out.println("Goodbye " + name); session.invalidate(); } } out.println(" "); } } session management state management document construction Conciseness (Servlets)
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Conciseness ( ) service { shared int users = 0; session Hello() { string name; show [[Enter your name: ]] receive[name=handle]; users++; show [[Hello, you are user number ]] ]] <[who=name]; } }
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Conciseness ( ) service { shared int users = 0; session Hello() { string name; show [[Enter your name: ]] receive[name=handle]; users++; show [[Hello, you are user number ]] ]] <[who=name]; } } session management state management document construction misc. Overall: 1/5 code
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 The Compiler Version 2.0: Version 2.0: Implemented in C (for UNIX / Linux) Implemented in C (for UNIX / Linux) Complete source code available Complete source code available –Approximately 2.5 MB source License: GPL (Gnu Public License) License: GPL (Gnu Public License) HTML CGI Scripts JavaScript HTTP Auth. Java Applets Complete Service Specification Complete Service Specification
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Homepage: Homepage: –Introduction –Examples –Ref. manual –Tutorials –Papers –Presentations –Downloads: src / bin src / bin –2 Recorded Presentations (MS & IBM Research)
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Publications Publications Concurrency ControlETAPS/FASE,1998 Concurrency ControlETAPS/FASE,1998 Runtime SystemComputer Networks J., 1999 Runtime SystemComputer Networks J., 1999 Dynamic DocumentsPOPL, 2000 Dynamic DocumentsPOPL, 2000 Form-Field ValidationWWW Journal, 2000 Form-Field ValidationWWW Journal, 2000 HTML ValidationPASTE, 2001 HTML ValidationPASTE, 2001 The ProjectTOIT Journal,2002 The ProjectTOIT Journal,2002 Syntax MacrosPEPM, 2002 Syntax MacrosPEPM, 2002 Document CachingWWW Journal, 2002 Document CachingWWW Journal, 2002
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 JWIG (Java) JWIG (Java)
GPCE 2003, Erfurt Dynamic Generation of XML September 22, 2003 Thank you!