Changes between Version 1 and Version 2 of UTGBCore/RequestDispatcher


Ignore:
Timestamp:
10/04/07 15:07:13 (18 years ago)
Author:
leo
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UTGBCore/RequestDispatcher

    v1 v2  
    55
    66== web.xml setting ==
    7 Add the following description into you web.xml.
     7Add the following description into your web.xml.
    88  * The lines param-name=base-package, param-value=(application base) specifies the location (base package name) where the RequestDispatcher searches recursively for RequestHandler implementations.
    99  * With the following setting, an HTTP request, e.g.,  http://localhost:8989/hello.action, is mapped to the request handler org.utgenome.gwt.utgb.server.app.Hello class. The upper letters are converted into the lower letters when mapping the request, e.g., Hello action can be accecced via hello.action URL.
     
    2727
    2828
     29=== Automatic Data Binding to Request Handler ==
     30
     31Hello.java class has serveral parameter values name and year:
     32{{{
     33
     34public class Hello implements RequestHandler
     35{
     36  private String name = "";
     37  private int year = 2000;
     38
     39  public void handle(HttpServletRequest request, HttpServletResponse response)
     40  {
     41      PrintWriter out = response.getWriter().println("Hello " + name + "(" + year + ")");
     42  }
     43
     44  public void setName(String name) { this.name = name; }
     45  public void setYear(int year) { this.year = year; }
     46}
     47
     48
     49}}}
     50
     51Our RequestDispatcher automatically set these parameter values from a given HTTP request. For example, an HTTP request  http://localhost:8989/hello.action?name=leo&year=2007 will invoke setName("leo") and setYear(2007).
     52
     53Note that, although the query string in the HTTP request consists of string values, our BeanUtil library
     54detects the data type to which the string should be translated by reading the class definition (in this example, Hello class).
     55 
     56
     57