File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Servlet parameters disappearing

Federico Pugnali

Joined: Sep 16, 2005
Posts: 3
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?

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2068
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

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.

Ben Souther

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
I agree. Here's the link:
subject: Servlet parameters disappearing
It's not a secret anymore!