Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Delivered-To: moderator for tomcat-dev@jakarta.apache.org Received: (qmail 55066 invoked from network); 17 Oct 2000 01:36:09 -0000 Received: from www.gaywalker.com (HELO gaywalker.com) (211.2.255.154) by locus.apache.org with SMTP; 17 Oct 2000 01:36:09 -0000 Received: from panache.co.jp (pc5.wintermute-unet.ocn.ne.jp [211.17.174.29]) by gaywalker.com (8.9.3+Sun/8.8.8) with ESMTP id KAA12740; Tue, 17 Oct 2000 10:36:16 +0900 (JST) Message-ID: <39EBAD7E.F97B7839@panache.co.jp> Date: Tue, 17 Oct 2000 10:38:06 +0900 From: Yuri Kazakov Organization: Panache X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: ja,ru,en MIME-Version: 1.0 To: tomcat-dev@jakarta.apache.org, Harry@Behrens.com Subject: Servlet - JSP POST data problem. Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Hello All, I have a servlet that reads POST data, implements business logic and calls JSP (RequestDispatcher.forward()) only for HTML decoration. JSP doesn't try to access any GET/POST parameters but anyway Jasper JSP servlet checks POST data and raise: java.lang.IllegalArgumentException: Short Read. I found out that many people already had the same problem as me, for example: Re: HttpUtil.parsePostData() and JSP problem, May 11 2000 RE: HttpUtil.parsePostData() and JSP problem, May 11 2000 Problem processing a Post with getRequestDispatcher.include(), Feb 14 2000 By the way, people from servlet mailing list (SERVLET-INTEREST@java.sun.com) think that this Tomcat/Jasper's behavior is not correct: Re: RequestDispatcher and POST data, 6 Jun 2000 I didn't find any solutions in mailing lists and changed ContentLength to avoid the problem. In brief: int c_length = request.getContentLength(); request.getRealRequest().setContentLength(0); go.getRequestDispatcher(path).forward(request, response); request.getRealRequest().setContentLength(c_length); Could anyone from Tomcat developers confirm that this intrusion to Tomcat is safe and will not cause any troubles. Thanks in advance. Sincerely, Yuri. --------------------------------------------------- /* change Content-Length */ int c_length = request.getContentLength(); if (session.getClass().getName().equals("org.apache.tomcat.session.StandardSession")) { /* Tomcat servlet container! */ Method[] ms = request.getClass().getMethods(); /* reflection games to make it */ for (int i = 0; i < ms.length; i++) /* compilable in non-tomcat */ if (ms[i].getName().equals("getRealRequest")) { /* class environment */ Object par = ms[i].invoke(request, new Object[0]); par.getClass().getMethod("setContentLength", new Class[] { int.class }). invoke(par, new Object[] { new Integer(0) }); }} /* dispatch to JSP page */ go.getRequestDispatcher(path).forward(request, response); /* change back */ if (session.getClass().getName().equals("org.apache.tomcat.session.StandardSession")) { Method[] ms = request.getClass().getMethods(); /* reflection games to make it */ for (int i = 0; i < ms.length; i++) /* compilable in non-tomcat */ if (ms[i].getName().equals("getRealRequest")) { /* class environment */ Object par = ms[i].invoke(request, new Object[0]); par.getClass().getMethod("setContentLength", new Class[] { int.class }). invoke(par, new Object[] { new Integer(c_length) }); }} ---------------------------------------------------