wood burning stoves 2.0*
The moose likes BEA/Weblogic and the fly likes junk characters in netui:form with enctype= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "junk characters in netui:form with enctype="multipart/form-data"" Watch "junk characters in netui:form with enctype="multipart/form-data"" New topic
Author

junk characters in netui:form with enctype="multipart/form-data"

carlos rivera
Greenhorn

Joined: Sep 03, 2009
Posts: 7
Hello all

I have a JSP that goes like this:



In others JSPs within the same app (each document share the same codification tag) I can add data with special characters like ñ, á , ö, ê , etc.
however, in this particular form, they're added to database as junk characters like á , ñ , ...
I've already changed my tables' codification to UTF-8, to no avail

I believe it has something to do with the enctype="multipart/form-data" parameter

Is there anything you can suggest to stop this from happening?
I'm using BEA Weblogic 8.1.3

Thank you in advance
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Are the special characters coming from the file ? The encoding problem might not be with the database but with the file itself. Perhaps it was saved with the wrong encoding ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
carlos rivera
Greenhorn

Joined: Sep 03, 2009
Posts: 7
no, the problem is the text being inserted in the database, i use the netui:fileupload for uploading an image to the server, and that works just fine.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

carlos rivera wrote:no, the problem is the text being inserted in the database, i use the netui:fileupload for uploading an image to the server, and that works just fine.


You read images with streams and encoding should not be a problem there. Text is a different matter. Does the problem occur when the file is uploaded or when the uploaded contents are inserted into the DB ?
carlos rivera
Greenhorn

Joined: Sep 03, 2009
Posts: 7
the problem occurs whether I upload a file or not, everytime I enter 'foreign' characters. When I print the text in console, BEFORE doing the insert to the DB, it's already corrupted. Weblogic is somehow changing the codification of text in this particular Form.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

It is probably not weblogic's fault. Set the encoding of the JSP page to display. If you are reading this input in some form (instead of having net UI read it automatically), then mention the encoding of the text.

This page http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html offers some good advice on encoding in its various forms.
carlos rivera
Greenhorn

Joined: Sep 03, 2009
Posts: 7
Deepak:

Is only when the enctype="multipart/form-data" parameter is removed form the <netui:form> tag, that everything works as expected (I can insert and retrieve accented characters).

I tried the suggestions you gave me, but the characters still change arbitrarily, and every JSP for data input and display are declared to be UTF-8 compliant.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Have you tried using commons file upload ? http://commons.apache.org/fileupload/

You should have no problem reading the characters if it is UTF-8 compliant and you use the commons upload API for multipart uploads.
 
Don't get me started about those stupid light bulbs.
 
subject: junk characters in netui:form with enctype="multipart/form-data"