File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet parameters disappearing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet parameters disappearing" Watch "Servlet parameters disappearing" New topic
Author

Servlet parameters disappearing

Federico Pugnali
Greenhorn

Joined: Sep 16, 2005
Posts: 3
Hi,
I have a strange problem regarding my web app. Basically there are a couple of functionalities where I submit a form with GET or POST and sometimes (not always, no pattern found, just submitting a form after calling some js) I don't get the parameters sent at the server. I put a sniffer and checked that the parameters always leave the browser. Then I have a System.out.println at my first filter (in doFilter) of request.getParameterMap.keySet() and when the problem occurs the println shows empty parameters ([]). Somehow the parameters disappear. This happens with the application running on a Tomcat 5.0.28 and also on a Websphere 5. The only clue that I have is that the Velocity pages with the forms where this happens has also previous calls to serverside methods via JSon-RPC. I see the JSon-RPC calls on the sniffer, but I cannot seem to connect them with the problem since there's no exception or error coming from json and since json runs in a different servlet. I really need help on this, any ideas?

Thanks,
Federico
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
to debug it, you can compare the code that works versus the code that doesnt work. you might some clue there.

as you mentioned, that it worked some times
Federico Pugnali
Greenhorn

Joined: Sep 16, 2005
Posts: 3
I mean sometimes with the same code (!).
Anyway I've found the problem. I'll try to explain it. The object registered for the JSon-RPC bridge was an inner class. The method accessed via JSon in this inner class then calls a method in its outter class. The outter class has a reference to the last HttpServletRequest. When thru the JSon call any code does a request.getParameter("anything"), although the logic goes ok, the next submit SOMETIMES looses its parameters. I reproduced the bug just with one line (the getparameter one). The failure seems to happen 1 out of 5 or 6 times. When I commented the request.getparameter lines (that has no sense in the JSon calls anyway) the problem didn't appear anymore. So one IF (if(JSonCall)) did the workaround. I still don't know if it's a JSon-RPC-Java bug. I hope my issue helps.

Federico
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Thank you for posting back.
Sounds like a hell of a problem to debug.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
GeeCON Prague 2014
 
subject: Servlet parameters disappearing