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!

passing japanese characters in hidden variables

Status
Not open for further replies.

Reddy316

Programmer
Jul 24, 2001
25
IN
Hi all,
I have a requirement to pass japanese characters using hidden variables from one jsp to another. Can anyone please tell me the most effective way of achieving this.

Thanks in advance,
Mahendra
 
This is very straightforward, just set the value of the hidden input in your JSP. Example:
Code:
<input type=&quot;hidden&quot; name=&quot;japaneseText&quot; value=&quot;<%= japaneseText %>&quot;>

Obviously you would have to initialize japaneseText for this example to work.

Also you need to make sure you set the proper Content-type for the JSP. This should be done at the top of the page. We usually use UTF-8 but it may or may not support the entire character set you need. You will need to determine that yourself. Example:
Code:
<%@ page contentType=&quot;text/html; charset=UTF-8&quot; %>

Note: if you view source on the JSP then you will see the value of the hidden inputs but most text programs do not support UTF-8 so you will not see Japanese text. To text this I suggest setting a hidden input with Japanese text and submitting another JSP which displays it. Remember you will also need to set the content to UTF-8 for that page as well. Lastly, UTF-8 is not supported by all browsers anything before IE 4 will not work and we have experienced some bugs with Netscape's support for UTF-8.

Hope this helps. Wushutwist
 
Hi Wushutwist,
Thanx for the reply. I have one more query, the japanese character set that we will be using will most probably be SJIS will this method work for that as well?

Thanx,
Reddy


 
I have never used it but if it is a valid HTML charset then you will be fine. The only problem is that most browser probably don't come equipped with that character set by default. Also if you want to display English in addition to Japanese you will need to see if SJIS supports the English. UTF-8 takes care of most of these problems. Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top