Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Could struts be corrupting my byte[]?

Status
Not open for further replies.

SuperMoonster

Programmer
Aug 11, 2005
59
BR
Hello, everyone.

I have an app which uses struts + hibernate. I was having a problem of corrupted blobs (which are treated by the app as byte[]), and so far I was blaming hibernate for that. But right now, making a test, I found out that my data gets corrupted BEFORE even being treated by hibernate. Here's what I have:

1. A jsp page that gets a String using html:text, property = descricao
2. An action form that has the descricao property as a byte[], together with its getters and setters
3. An action that takes data from this action form and puts it in my object, which by the way also has this property as a byte[], with its getters and setters.

So, what I wanna do is get this String and put in a blob field. Here comes my action code:

cor.setCor(addCorForm.getCor());
cor.setNome(addCorForm.getNome());
cor.setDescricao(addCorForm.getDescricao());
CorService.getInstance().addCor(cor);

That's basically it: I set the properties and add. The thing is that if I get the byte[] value of addCorForm.getDescricao() and convert it to a string, it gives me NULL or a lot of weird characters. That means my data is getting corrupted right there, before its insertion.

Another proof of it, is that if I insert a line in this table using the database's tool, I can retrieve the information through my application.

So... database tool = correct data. App = incorrect data, even before adding the object in the DB with hibernate. What I can think here is struts is corrupting... could it be?

1. Is html:text the correct component I have to use for this?
2. Do I have to make any conversion, being that I insert a String and it gets a byte[]?

How do you guys do it? Thank you all very much for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top