Well, actually, as far as I tested, the problem happened for all values 
entered. I suppose the real reason is like David said: probably struts 
doesn't make the conversion, or at least doesn't make the right conversion.

I wrote converter functions and so far they are working well. So I suppose 
the problem is solved, though I'll only be sure as time goes by.

Thanks you all

On 9/13/05, Andreas Solarik <[EMAIL PROTECTED]> wrote:
> 
> Just my 2 cents:
> 
> We had a horrible/stupid problem creep up on us with the sign extension in
> java when working with bytes (which are 2s complement, just like all other
> primitive number types). Strange things would happen when the value of the
> byte was greater then 127. In hindsight, it was an elementary problem, but
> it caught us off guard and we wasted half a day looking in the wrong 
> places.
> Now we have lots of things like:
> 
> byte b=(some 8bit bit pattern);
> int i=b & 0x00ff; // <--- that is the important thing if you want to treat
> the bit pattern as unsigned
> 
> its not nice, but works (except if i have a typo). Maybe someone will 
> learn
> from our mistakes. Because its *always* easier to learn from other peoples
> mistakes than getting stuck on your own. Maybe your byte and String 
> problems
> only occured when the respective ASCII code had a "1" as the MSB (sign bit
> for 2s complement numbers)?
> 
> Andreas
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: David Delbecq [mailto:[EMAIL PROTECTED]
> Gesendet: Dienstag, 13. September 2005 09:52
> An: Struts Users Mailing List
> Betreff: Re: Could struts be corrupting my byte[]?
> 
> 
> Le Lundi 12 Septembre 2005 16:36, Letícia Álvares Barbalho a écrit :
> > I did what you suggested and changed from byte[] to String, leaving to
> > conversion to hibernate's level. It did solve the problem, thank you.
> >
> > But I'm wondering here... I still got a problem with the charset, don't 
> I?
> >
> 
> Well if String is correct in form, you don't have charset problems in the
> struts
> part (decoded ok from browser's POST to ActionForm). However, am not sure
> struts handle automatic conversion from String to byte[]. When your action
> forms is filled,
> here is what happens in non-fileupload forms:
> - Browser send form field in a specific encoding.
> - Servlet container or commons-fileupload decodes submitted datas and
> convert them to string parameters
> - Struts take all submited parameters and uses the beanutils populate()
> method to fill ActionForm
> - For each parameter, populate tries to convert the String to the
> appropriate Setter parameter using converters
> - In the case of a setXXX(byte[]) signature, the ByteArrayConverter is 
> used.
> 
> As far as i can see in this converter source, it's purpose is to convert a
> string like "58,107,24,89" into byte[] {58,107,24,89}
> which is not what you want i think.
> 
> Why i suggested you to explicitly specify the charset used in String to
> byte[] is because you are storing text in blob on your database,
> that means you must have decided when designed the database, which charset
> you wanted to use (i assumed utf-8).
> You must remain consistent in your various byte[]<->String conversion to
> this blob field.
> I suggested UTF-8, but maybe some other thing might be more suitable for
> you.
> 
> Anyway, once you have decided a charset for your blob, stick with it.
> 
> --
> David Delbecq
> Royal Meteorological Institute of Belgium
> 
> -
> Is there life after /sbin/halt -p?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Letícia Álvares Barbalho
[EMAIL PROTECTED]

Reply via email to