-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Aryeh,
On 3/2/2010 7:12 PM, Aryeh M. Friedman wrote:
> Christopher Schultz wrote:
>>
>> If that string above is your entire POST request body, then it's not
>> properly formatted. Instead, it should be:
>>
>> call=8347812459870132405987234985023450987
>>
>> or whatever. The parameter has to have a name :)
>
> Design decision for two reasons:
Just so you know, your design decision means that POST will /never/ work
using request.getParameter.
> 1. If we are already decoding the request from hex to plain text
> mightiest use getReader()
>
> 2. Our app needs to support several frontends (not just the web via a
> servlet)
I don't believe either of these issues should present a problem. I would
think you could do the following as a POST request body:
call=[encode("call=36418724r58734523874")]
...and then just do request.getParameter("call") whether it's GET or POST.
> Just for reference here is the refactored servlet with any trade secret
> code removed (all the tomcat<-->servlet logic is kept)
[snip]
> try {
> call=StringUtil.hexToString(
> readRequest(request)).substring(5);
> } catch(IOException e) {
> write out error in custom format
> }
Good luck with that code.
> private String readRequest(HttpServletRequest request)
> throws IOException
> {
> if(request.getMethod().equals("GET"))
> return request.getQueryString();
Oh, so you were using the whole query string and not just the value of
one parameter? Wow, you've really changed-up the whole thing, eh?
> String out="";
> Reader reader=request.getReader();
>
> // reading all the content in one read causes problems
> sometimes so we read it char by char
This comment is an indication of something wrong. :(
> for(int i=0;i<request.getContentLength();i++)
> out+=(char) reader.read();
Nice.
> private static final long serialVersionUID=0L;
This class isn't serializable. It's odd to set a serialVersionUID for a
class that isn't serializable. Also, it's weird to set its value to
zero. <shrug>
Hey, if what you've got here works, then who am I to interfere?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkuP39QACgkQ9CaO5/Lv0PBOiQCffq5J3k23zHTrSAnwrxhAVP6N
bwMAoJT3NIl3+ALbqR4yfFdGv6E5Nk6J
=jClC
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]