Logo of Bento frameworkspaceObject Oriented Programming


Source code example of RequestParser


   // Get the instance of RequestParser.
   RequestParser reqParser=RequestParser.getInstance();

   // Parse the HTTP request only in the very first stage
   // and create ParsedRequestParameters object.
   ParsedRequestParameters params=reqParser.parseSimple(req);

   // Get the request parameter value for "param1", in the
   // form of URL-encoded String.
   // At this point, all parameters are left in the form of
   // URL-encoded String.
   String encoded=params.getEncodedString("param1")

   // Get the request parameter value for "param2", in the
   // form of byte arrays.
   // At this point, only this parameter is converted to the
   // byte arrays.
   // The rest of parameters are still left in the form of
   // URL-encoded String.
   byte[] byte=params.getDecodedBytes("param2")

   // Get the request parameter value for "param3", in the
   // form of the decoded String (that is the original String).
   // At first, this method converts the specified parameter
   // to the byte arrays.
   // Then, it converts the byte arrays to the decoded String.
   // The rest of parameters are left unchanged.
   String decoded1=params.getDecodedString("param3");

   // Now, let's play with "param2" again.
   // Get it in the form of the decoded String.
   // Because the specified parameter is already converted to
   // the byte arrays (see above), this method only converts
   // those byte arrays to the decoded String, and that all.
   // The rest of parameters are left unchanged.
   String decoded2=params.getDecodedString("param2");


Copyright © 1997-2007 OOP-Research CorporationTM, All Rights Reserved.