This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi I am having a question on getting the parameters and values from a servletRequest. Because I have to send more than 100,000 parameters & value pairs back to servelt after the applet finishes processing the data, (cause the applet must send the results back to servlet and then, the servlet can save the updated data to a database), in order to save the net work transfer time, I use gzip to zip the servletRequest query string. Everything is fine during at the networks, but when the servlet wants to process the query string, it has no way to get all the parameters & value pairs back cause the gzip has changed the query string. I mean I can restore the query string back to a string, but the restored string is not the same the query string any more. I have the same parameters & value pairs, but I am not able to retrieve the parameters (values) using request.getParameter()(request.getParametersValue()). Is there any way such that I can put a string which has parameters & value pairs into a servletRequest object so that I can use request.getParameter() or request.getParametersValue() methods?. BIW, how was the servletRequest implemented? Is there a way that I can view the source code? Thanks. Have a nice weekend. Howard
hi howard, i am surprised how u do zip on the querystring! can u tell me how to do it if we want? an example code will be a great thing to post for this... COMING TO UR PROBLEM, why dont' u put all ur name/value pairs in say Properties object and then zip that object and unzip at the servlet side again? if u can do that then ur problem can be solved i guess.. also, please try to post zip/unzip code to give me the idea how it works... regards maulin.
i don't know why you are trying to put the string again into a servelet request object.directly you can tokenise the name=value pairs using the delimeter & and process them. what will be the difficulty with that for you?
Excuse me but if you have to send 100,000 parameters in a request to a servlet you may have to rethink your design. I have no idea what you want to do but shouldn't you consider sending a compound object (a HashMap maybe?) via one of the Streams, to the server from the applet? Just a thought...
Tony Alicea Senior Java Web Application Developer, SCPJ2, SCWCD
May be you want to try using a URL connection to connect the applet and the servlet and pass data as a stream using the connection. Kris.
Joined: Nov 04, 2001
hi the question here seem not "how to pass the params" but how to make those COMPRESSED and then pass... thats what understand... correct me if i'm wrong.. regards maulin
Joined: May 06, 2002
Dear All Thank you very much for the quick replies. TO Maulin: The zip/unzip is pretty easy. Since I am not the only guy who is in the project. I am afraid I can not post the zip/unzip code here since this piece of code was developped by my team-mates. But I can give you a hint. It is somthing like GZIPInputStream stream, then stream.toStrin(). I hope you can understand me, and hope that this post can help you.
TO Lakshmi Using tokens to parse the request string is a common idae. But I am wondering, maybe by using tokens, the processing speedm will be lower than the speed of derectly using request.getParameterValues(), especially when the string is very long (with a length of over 1,000,000) and each token is pretty samll (with a length less than 10). Actually I am using tokens, but the problem is that I need to retrieve the data (tokens) quickly and to allow my servlet use not much memory. The key point of my question is that if possible, I want to know how the methods(request.getParameterValues(), request.getParameter(), ..) are implemented, and what kind of datastructure and algorithm are used.
To Tony I think setting up a hashtable at client side is not feasible in my case coz the hashtable will lower the proccessing speed and increase the client side memory usage. I will use a hashtable at the server side for sure.