Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 16465 invoked from network); 3 Mar 2010 00:12:44 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Mar 2010 00:12:44 -0000 Received: (qmail 61583 invoked by uid 500); 3 Mar 2010 00:12:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 61467 invoked by uid 500); 3 Mar 2010 00:12:35 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 61458 invoked by uid 99); 3 Mar 2010 00:12:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 00:12:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aryeh.friedman@gmail.com designates 209.85.218.215 as permitted sender) Received: from [209.85.218.215] (HELO mail-bw0-f215.google.com) (209.85.218.215) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 00:12:27 +0000 Received: by bwz7 with SMTP id 7so776825bwz.24 for ; Tue, 02 Mar 2010 16:12:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=F+CfYAhAPPtuU3c3vIIMboyOTVzsZNe4yPCV5jG+SZU=; b=BVAAWCXzN4VLokHUqn4hU8lvSrDXxWIY5DXPusPl8Mc84f4sx9Ffc3v+kwJAFigoqL eGEIvDmRla2rAbWhhyAQBgcRrhgE44U69ypeRhJrf0KNx2rei2rG/JVOEPR3cdyLKBrA GN5+FVfMrLAdGmiRkbxDHU+svLWRZ7Q1l2/fc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=R7hkWGsYOXMY665B3Na0vfv+bABIr8vd/M6cmA9KixnDO7H5cSaOf/Gd+gUwR5N9rX NxWQmwnq4VDponGS1M6u+3oD8BqM9/1IutcwyHwO0AH4N90HOuC8wwolwQRn4NGx6ioN oVjUWQ5OcjulhtH9N5tnzni8a/xHM90xnuWwM= Received: by 10.204.10.151 with SMTP id p23mr5305173bkp.80.1267575126342; Tue, 02 Mar 2010 16:12:06 -0800 (PST) Received: from aryeh-desktop.istudentunion.com (ool-44c0cd7a.dyn.optonline.net [68.192.205.122]) by mx.google.com with ESMTPS id p13sm6134828bkp.3.2010.03.02.16.12.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Mar 2010 16:12:05 -0800 (PST) Message-ID: <4B8DA953.8000808@gmail.com> Date: Tue, 02 Mar 2010 19:12:03 -0500 From: "Aryeh M. Friedman" User-Agent: Thunderbird 2.0.0.23 (X11/20100120) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: unified doXXX() References: <4B89CE2A.3000104@gmail.com> <4B8A8B17.2050200@pidster.com> <4B8B744C.9080608@gmail.com> <4B8BA461.10906@apache.org> <4B8CB569.3070507@gmail.com> <4B8D5384.3060400@christopherschultz.net> <4B8D6511.3070104@gmail.com> <4B8D78A6.7010001@christopherschultz.net> <4B8D79A4.6080604@gmail.com> <4B8D7BE0.5060601@christopherschultz.net> <4B8D7F38.9040509@gmail.com> <4B8D97DB.2060104@christopherschultz.net> In-Reply-To: <4B8D97DB.2060104@christopherschultz.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Christopher Schultz wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Aryeh, > > On 3/2/2010 4:12 PM, Aryeh M. Friedman wrote: > >> Also forgot to mention I already refactored the servlet to use pure >> hex encoding (namely we convert the entire request into a hex string >> so for example a old format message of >> "call=default.Session.getSession()" gets translated into >> "63616c6c3d64656661756c742e53657373696f6e2e67657453657373696f6e2829" >> >> > > If that string above is your entire POST request body, then it's not > properly formatted. Instead, it should be: > > call=8347812459870132405987234985023450987 > > or whatever. The parameter has to have a name :) > Design decision for two reasons: 1. If we are already decoding the request from hex to plain text mightiest use getReader() 2. Our app needs to support several frontends (not just the web via a servlet) Just for reference here is the refactored servlet with any trade secret code removed (all the tomcat<-->servlet logic is kept) // src/backend/servlet/Servlet.java package backend.servlet; import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import backend.util.StringUtil; // hex encoding/decoding public class Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { handleRequest(request,response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { handleRequest(request,response); } private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException { // not possible to do custom error reporting yet because we have no writer to write to PrintWriter pw=new PrintWriter(response.getWriter()); String call=null; try { call=StringUtil.hexToString( readRequest(request)).substring(5); } catch(IOException e) { write out error in custom format } code to do something with the request } private String readRequest(HttpServletRequest request) throws IOException { if(request.getMethod().equals("GET")) return request.getQueryString(); String out=""; Reader reader=request.getReader(); // reading all the content in one read causes problems sometimes so we read it char by char for(int i=0;i