• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to submit and display Unicode data(non English) on JSP page

 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!!
Greetings for the day.
i have a jsp page which contains two text areas inside two separate form tags. i want to submit unicode date in one textarea and display it in another. But nothing is working for me. i have to show basically all Indian Languages and english as well. kindly help me. here is the code of it


i am also using Struts 2 and apache tomcat server
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankush,
Does your page display correctly?
You could also add name attributes to your elements(forms, buttons, etc...). That will make them easier to reference.
And it is advisable not to put a dot in names of elements.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes the page displays correctly. I am in initial phase of development and looking to get this basic functionality to work .lot more to be added to psges
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i understand you well, you want to type something in first textarea and upon click on first submit button this content gets displayed in second textarea. Am i right?
But to start with, it is advisable to remove the dot in the first textarea name.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply and understanding Paul and yes you understood right. Regarding the dot in text area's name "contentBean.data" i want to clarify that i am using struts and this name is done as per the struts 2 application . contentBean is the name of object of a pojo class and data is the name of a variable of that class.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A solution will be to make your input type
button and use javascript in onclick event
to copy the content of textarea 1 to textarea 2.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul thanks for the reply, but my target is not to copy and paste.
i want to submit data through text area one and display the submitted data on text area 2. Please understand the issue.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please any one here can solve my problem? Please help me out as i am not finding any way to do this
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Paul thanks for the reply, but my target is not to copy and paste.

I think a small misunderstanding exists. I never meant a copy and paste. I said you could use javascript to make contents of your two textareas equal.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Ngom wrote:

Hi Paul thanks for the reply, but my target is not to copy and paste.

I think a small misunderstanding exists. I never meant a copy and paste. I said you could use javascript to make contents of your two textareas equal.


Hi Paul let me clear you the problem by an example because you are not getting the issue:-
Lets say we have a file of unicode data and you need to upload and display on a JSP page.
and also it is not the matter of making the values of text areas equal

Hope this gives you a clue of what the problem is.

I hope this time you help me out .
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankush,
It looks like my indications did not help.
So i am sure other people will come in
so as to offer help.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But nothing is working for me.

What does this mean? What does the page do now, and how is that different from what you were expecting it to do?
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello greetings for the day!
I think i must discuss with you the steps i am doing:-
1) I am copying some unicode data to text are one and it displays the data fine ,no issues till here.
2) I submit this data and the data goes to my action class and the bean class object is set with the data.
3)The submitted data comes back to the same jsp page into the second text area.
4) Now the data displayed is only the uniciode value like /u425d ,etc
5)unicode values are not converting at this point of time to proper strings.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by using POST in your form instead of GET; that way you can be sure that URL encoding does not get in the way.

How are you handling encoding of the data on the server?
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup the method is post now.
at server side i don't know how to configure it. but after doing google i found that
in server.xml i need to do this ""
but it is already configured the same way.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. So:
Ulf Dittmer wrote:How are you handling encoding of the data on the server?
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:OK. So:
Ulf Dittmer wrote:How are you handling encoding of the data on the server?



I am not getting what are you trying to say. I have configured the server as i understood .Please kindly let me know what else need to be done at server side.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your description it would appear that somewhere between sending the data to the server, and displaying data that was received back from the server, it gets converted from Unicode to some other notation. So the question is: what does the code do with that data? Converting characters from UTF-8 to the "\u425d" notation does not happen by itself; something must trigger it.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i receive the data i only initialize my bean object with that data. and with the help of that bean class variable i display it back on the jsp page
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that's the relevant part. Tell us all about it :-)
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i am pasting my action class code here



and the pojo class




nothing else i have to share with you. I hope it helps
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you copy & paste your request and response headers?
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry but how to do that?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the tools in the browser. You'll find them in the menus.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help.

I have found this

Headers.png
[Thumbnail for Headers.png]
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as i can see there is content type in response header is charset=ISO-8859-1. but i don't know how to fix it
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i got the solution after observing the response header.
i just put

thank for helping me.
but is there any way so that i can have the response.setCharacterEncoding("UTF-8"); for all my jsp pages?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a central controller through which all requests are channeled to the JSPs? That would be a good place.
 
Ankush Seth
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i am using struts
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do you have a central controller through which all requests are channeled to the JSPs?

Hi Ulf,
Did you want to mean responses?
Kind regards
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request handling involves sending the response, IMO, but I suppose it's possible to have a controller that handles all requests, but not all responses :-)
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really a job for the controller. Tomcat comes with a Filter (in the examples) to set the character encoding everywhere. It's quite simple, you just specify a Filter on any request (/*) setting character encoding on the response and calling the filterChain.doFilter().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!