Thanks Martin for the reply. I have removed all calls to getParameter family of methods on the request object and I can still see the issue. I have checked all servlet filters - No processing has been done on request object. This issue is seen when content-type=application/x-www-form-urlencoded. Issue is not seen when content-type=text/xml.
Two questions A) How to know from where getParameter is being called from the code? B) Is it okay to use content-type=text/xml Regards, Swati -----Original Message----- From: Martin Gainty [mailto:mgai...@hotmail.com] Sent: Monday, July 27, 2009 5:23 PM To: Tomcat Users List Subject: RE: HttpServletRequest.getReader() returns nothing answered by markt here https://issues.apache.org/bugzilla/show_bug.cgi?id=47410 the 3.1 part of 2.5 Servlet Spec located at http://www.scribd.com/doc/7395371/JSP-Servlet-JSTL-Specification reads if request is a 1)http or https request 2)http method is a POST 3)content-type=application/x-www-form-urlencoded 4)servlet has made a initial call on any of getParameter family of methods on the request object if the (above) conditions are met the post-form-data will no longer be made available for reading by post objects InputStream do you expect the behaviour to be different than the spec Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Subject: HttpServletRequest.getReader() returns nothing > Date: Mon, 27 Jul 2009 02:38:38 -0700 > From: swras...@cisco.com > To: users@tomcat.apache.org > > Hi All, > I am doing a HTTP POST on a servlet running on my local box. For this, > I am opening a socket on port 80 and sending the data. > When I call getReader() on HttpServletRequest object, I cannot find > any data. Instead of Calling getReader(), if I call getParameter() or > getParameterMap() on HttpServletRequest object, I can retrieve the > data which has been posted > > This works well on Linux 4 with apache version 2.0 and tomcat version > 4.X and jk2 i.e. getReader returns data. > The issue is seen on Linux 5 with apache version 2.2.3 and same tomcat > version 4.X and mod_jk1.2.27. > > Any clues as to what is going wrong? > > Using tcpdump, I have seen the request - It looks as expected. > ---------------------------------------------------------------------- > -- > ---------------------- > POST /servlet/Help HTTP/1.0 > Content-Length: 17 > Content-Type: application/x-www-form-urlencoded > > Want to send this > ---------------------------------------------------------------------- > -- > ---------------------- > > SERVER CODE: > -------------------- > getReader() on HttpServletRequest object returns me BufferedReader > object. > If I call read() on buffer, I get -1. If I call readLine() on buffer, > I get NULL. > > This is how I am calling in my servlet: > java.io.BufferedReader _buffer = req.getReader(); > System.out.println("****Is Buffer object ready " + > _buffer.ready()); > System.out.println("****Is Buffer object char: " + > _buffer.read()); > System.out.println("****Is Buffer object line: " + > _buffer.readLine()); > > Instead of Calling getReader(), if I call getParameter() or > getParameterMap() on HttpServletRequest object, I can retrieve the > data which has been posted. > > > > CLIENT CODE: > ----------------- > // Construct data > String data = "Sending simple data"; > > // Create a socket to the host > String hostname = "127.0.0.1"; > int port = 80; > InetAddress addr = InetAddress.getByName(hostname); > Socket socket = new Socket(addr, port); > > // Send header > String path = "/servlet/Help"; > BufferedWriter wr = new BufferedWriter(new > OutputStreamWriter(socket.getOutputStream(), "UTF8")); > wr.write("POST "+path+" HTTP/1.0\r\n"); > wr.write("Content-Length: "+data.length()+"\r\n"); > wr.write("Content-Type: > application/x-www-form-urlencoded\r\n"); > wr.write("\r\n"); > > // Send data > wr.write(data); > wr.flush(); > > // Get response > BufferedReader rd = new BufferedReader(new > InputStreamReader(socket.getInputStream())); > String line; > while ((line = rd.readLine()) != null) { > // Process line... > System.out.println(line); > } > wr.close(); > rd.close(); > > Regards, > Swati _________________________________________________________________ NEW mobile Hotmail. Optimized for YOUR phone. Click here. http://windowslive.com/Mobile?ocid=TXT_TAGLM_WL_CS_MB_new_hotmail_072009 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org