• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 457
  • Last Modified:

how to pass the japnesh char to URL


Hi ,

how to pass the japnesh  char to URL in java script, i tried with escape, encode URI method but no use ? its in UTF-8 format

is there any other way ?
0
Sathish David  Kumar N
Asked:
Sathish David  Kumar N
  • 44
  • 23
  • 22
  • +1
2 Solutions
 
CEHJCommented:
Please post your current code
0
 
CEHJCommented:
0
 
Sathish David Kumar NArchitectAuthor Commented:
Please check the below code !!

var sName= document.appActRes.sName.value;
			var userFNF= document.appActRes.userFNF.value;
			var userLNF= document.appActRes.userLNF.value;
			var conFNF= document.appActRes.conFNF.value;
			
			var conLNF= document.appActRes.conLNF.value;
			
			
			var url = "/xxx/xSearch.do?action=popupfetch&screenName=app&fetch="+type+"&sName="+sName+"&userFNF="+userFNF+"&userLNF="+userLNF+"&conFNF="+conFNF+"&conLNF="+conLNF;
			newwindow=window.open(url,"name","height=500,width=550,scrollbars=yes"  );
			if (window.focus) {newwindow.focus();}

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
CEHJCommented:
Try the above

var url = encodeURI("/xxx/xSearch.do?action=popupfetch&screenName=app&fetch="+type+"&sName="+sName+"&userFNF="+userFNF+"&userLNF="+userLNF+"&conFNF="+conFNF+"&conLNF="+conLNF);

Open in new window

0
 
Sathish David Kumar NArchitectAuthor Commented:
Same result no change !! :(
0
 
CEHJCommented:
What exactly is the result?
0
 
leakim971PluritechnicianCommented:
Do you have a live link to have a look to your page ?
0
 
CEHJCommented:
Please past the result of

alert(uri);

here
0
 
Sathish David Kumar NArchitectAuthor Commented:
check
0
 
CEHJCommented:
That looks ok to me. Precisely what is the problem you have? Are you sure it's not more like it's not making the request you expect?
0
 
leakim971PluritechnicianCommented:
0
 
Sathish David Kumar NArchitectAuthor Commented:
So this URL Parameter i will get the value in the java (request.getParameter()) its giv junk value....
0
 
Sathish David Kumar NArchitectAuthor Commented:
check
check this image . right side is parent window  and left side is popoup window the value is not set !  check
0
 
CEHJCommented:
What does the below give on your struts host vm?


System.out.println(System.getProperty("file.encoding"));

Open in new window

0
 
CEHJCommented:
Those browser screenshots could indicate one or more of the following:

a. You don't have UTF-8 encoding enabled
b. You don't have Japanese font support

Open http://www.columbia.edu/kermit/utf8.html in the same browser and go down to 139. Make sure the Japanese is displayed properly
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>System.out.println(System.getProperty("file.encoding"));

s its says Cp1252 how its possible ?
 i have char -encodeing fileter there i am setting UTF-8 ?

How to find out where its cahnge to Cp1252?
0
 
CEHJCommented:
OK. That's not necessarily a deal breaker. If you've got a filter set up, you're probably OK. It just indicates that your platform is not natively Unicode. What was the result of my last comment?
0
 
Sathish David Kumar NArchitectAuthor Commented:
s its display properly .
0
 
CEHJCommented:
Please also post (pref as attachment) the source code of that page you pictured
0
 
Sathish David Kumar NArchitectAuthor Commented:
which one ?
popup or parent ?  
0
 
CEHJCommented:
Both would be good
0
 
Sathish David Kumar NArchitectAuthor Commented:
Parent window  
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/displaytag-11.tld" prefix="display" %>

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/x/ddtabmenufiles/ddcolortabs.css" />
<link rel="stylesheet" type="text/css" href="/x/css/x.css" />
<script type="text/javascript" src="/x/ddtabmenufiles/ddtabmenu.js"></script>
<script type="text/javascript" src="/x/js/x.js"></script>
<script language="javascript" charset="UTF-8" src="./js/approveAct.js" > </script>
<script language="javascript" src="./js/datetimepicker.js"> </script>

Open in new window

0
 
Sathish David Kumar NArchitectAuthor Commented:
do you need full JSP ?
0
 
CEHJCommented:
Yes, that would be best. Attach as text file please
0
 
Sathish David Kumar NArchitectAuthor Commented:
x.txt parent
0
 
Sathish David Kumar NArchitectAuthor Commented:
CHild
x.txt
0
 
CEHJCommented:
Take a close look at the filter - it might not be getting called (put some debug in it)
0
 
Sathish David Kumar NArchitectAuthor Commented:
do u want that filter code ?
0
 
objectsCommented:
you need to make sure your container is configured to use UTF8
0
 
Sathish David Kumar NArchitectAuthor Commented:
how to ensure that ?

container is configer with UTF-8 format ?
0
 
objectsCommented:
what container r u using?
0
 
Sathish David Kumar NArchitectAuthor Commented:
Servlet 2.4
0
 
objectsCommented:
are you using tomcat?
0
 
Sathish David Kumar NArchitectAuthor Commented:
S tomcat only .
i set that value in server.xml also
0
 
objectsCommented:
post your server.xml and I'll check it
0
 
Sathish David Kumar NArchitectAuthor Commented:
0
 
Sathish David Kumar NArchitectAuthor Commented:
URIEncoding="UTF-8" i set like this in port 8080
0
 
objectsCommented:
then where do you get the parameter value from the request?
0
 
Sathish David Kumar NArchitectAuthor Commented:
In my action (java) class .only
0
 
objectsCommented:
can you post that code.
and where you then pass the value to the page for rendering
0
 
Sathish David Kumar NArchitectAuthor Commented:
http://35082133#

in tha command i metion that i am passing the value to action class .

in my action normal request.getParmater() only i used ?
0
 
Sathish David Kumar NArchitectAuthor Commented:
My filter class  
private String encoding; 
		  
		   public void init(FilterConfig config) throws ServletException 
		   { 
		    encoding = config.getInitParameter("requestEncoding"); 
		 
		    if( encoding==null ) encoding="UTF-8"; 
		   } 
		 
		   public void doFilter(ServletRequest request, ServletResponse response, FilterChain   next) 
		   throws IOException, ServletException 
		   { 
		  
		    if(null == request.getCharacterEncoding()) 
		      	
		      request.setCharacterEncoding(encoding); 
	    	  response.setContentType("text/html; charset=UTF-8");
		      response.setCharacterEncoding("UTF-8"); 
		      next.doFilter(request, response); 
		   } 
		 
		    public void destroy(){}

Open in new window

0
 
objectsCommented:
> http://35082133#

wheres the value coming from in that code.
best to check that it is valid there before you pass it in the request

> in my action normal request.getParmater() only i used ?

then what do you do with it? how is it passed to the view?

> My filter class  

the filter is not really related to your problem
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>then what do you do with it? how is it passed to the view?


getting  values and pass to query and get some values .

set (setAttribute) both the values (getting from screen value & query result)

>>> wheres the value coming from in that code.

Its from DB .

>>>>>>best to check that it is valid there before you pass it in the request

How to check that ? I used check like this
System.out.println(System.getProperty("file.encoding"));
s its says Cp1252 how its possible

0
 
objectsCommented:
is the data in the database ok?
are you using utf8 for the database connection?

> How to check that ? I used check like this

try displaying the attribute directly on the page that is building the url and making the request

> System.out.println(System.getProperty("file.encoding"));

That doesn't really make a difference in your case
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>are you using utf8 for the database connection?
you mean db connection class ? its also java calss so request coming from filter only right ?

If i am worng how can i set that ??

0
 
objectsCommented:
generally you set it in the connection string, depends on the db and driver

add some logging to output the value in various steps in the process so you can determine at which point it becomes corrupt
0
 
CEHJCommented:
I thought it was info from the form that was corrupt, not db stuff dravidnsr?
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>> add some logging to output the value in various steps in the process so you can determine at which point it becomes corrupt

While coming from Jsp page only the format is changed.

>>>>>> I thought it was info from the form that was corrupt, not db stuff dravidnsr?
K how can i correct that ?
0
 
CEHJCommented:
>>>>>> I thought it was info from the form that was corrupt, not db stuff dravidnsr?

Well firstly i'm asking YOU a question there actually. Is that the case?
0
 
objectsCommented:
> K how can i correct that ?

there is no form is there. So nothing to correct there :)

0
 
Sathish David Kumar NArchitectAuthor Commented:
Any other input ??
0
 
CEHJCommented:
I'm still waiting for you to answer my question...
0
 
Sathish David Kumar NArchitectAuthor Commented:
which one??
0
 
CEHJCommented:
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>>>>>>>> I thought it was info from the form that was corrupt, not db stuff dravidnsr?

How can i know that form corrupt or not ?
0
 
Sathish David Kumar NArchitectAuthor Commented:
I didnt change anything its working fine in my pc . But i deployed the code in UAT  envi . its again give junk value ?  how thats posible ............
0
 
objectsCommented:
what form are you referring to?

Did you add the logging as I suggested above?  That should show you where the text is getting corrupted
0
 
objectsCommented:
> I didnt change anything its working fine in my pc . But i deployed the code in UAT  envi . its again give junk value ?  how thats posible ............

check if the default encoding on the two boxes is different
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>>>>>what form are you referring to?

I referred both the suggestion because i need solution

 .  

>>>>>>check if the default encoding on the two boxes is different
Two boxs means ?  i put the same log in( u suggest above )  and directly deployed in that code i didnt remove log . i see in the log file the text file corrupt in UAT but not Dev
0
 
objectsCommented:
> I referred both the suggestion because i need solution

I meant what html form are you referring to in your earlier comment. Thats the first time you had mentioned you had a problem with a form. If you can show me the form you think is corrupting it then I can check it for you.

> Two boxs means ?  i put the same log in( u suggest above )  and directly deployed in that code i didnt remove log . i see in the log file the text file corrupt in UAT but not Dev

sounds like a different default encoding so check the default encoding on the UAT box
If thats the case then to fix it you can either change the default encoding, or make sure your code explicitly specifies the encoding to use everywhere

Worth adding logging in various places in the logic flow so you can see at what point it becomes corrupt. eg. is it corrupt in the datase, is it corrupt after being read from the db, is it corrupt when rendered on the page ....
0
 
objectsCommented:
> Two boxs means ?

sorry, I meant the two computers Dev and UAT
0
 
CEHJCommented:
Please verify that you deployed the filter to UAT and that it's being called
0
 
Sathish David Kumar NArchitectAuthor Commented:
my ant bulider have encoding format as ISO is that effect the code ??
0
 
CEHJCommented:
>>my ant bulider have encoding format as ISO is that effect the code ??

Certainly if your code actually contains Japanese chars, these will be unrepresentable in ISO, so, yes
0
 
objectsCommented:
> my ant bulider have encoding format as ISO is that effect the code ??

where is it using ISO?
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>>
where is it using ISO?

In my build.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Deploy From Eclipse to Tomcat" basedir=".">
0
 
objectsCommented:
thats fine :)
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>>
add some logging to output the value in various steps in the process so you can determine at which point it becomes corrupt


what kind of log i will put . before that i put System.out.println(System.getProperty("file.encoding"));
put it say project encoding format !after i convert the hole project in to UTF-8 format  still have facing problem !!
0
 
Sathish David Kumar NArchitectAuthor Commented:
i paln to do in byte array  for debugging

new String (resultSet.getString(1).getBytes(),"UTF-8") if i use this that popup will coming like ?????? mark ??

How can i know which encoding format is coming from DB ?
0
 
CEHJCommented:
What you should do is limit the possible input values to as few as possible - preferably one only. Is that possible?
0
 
Sathish David Kumar NArchitectAuthor Commented:
ya its only one not more than that !! (its search screen and fetch only one value )
0
 
CEHJCommented:
Please show (in Unicode escaped format) what the value of the field should be, e.g.


\u20ac\u1159
0
 
Sathish David Kumar NArchitectAuthor Commented:
which one??
0
 
CEHJCommented:
The one field you're using, which you just mentioned:

>>ya its only one not more than that !!

(use the same value all the time when you're testing)
0
 
Sathish David Kumar NArchitectAuthor Commented:
its search screen result page i am using jstl and some java script coding to use the same screen for all .

all search pages are working fine . which one you need for unicode format??
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>ya its only one not more than that !! (its search screen and fetch only one value )

    it fetch only one column but that column have more than 0ne vaue
0
 
Sathish David Kumar NArchitectAuthor Commented:
actually my problem is

with form submit i can get the correct values  (Japanese values) so its set proper char-set format

but with out form submitting like pop up window open(i want to retrieve some values so iam going with that url for popup) so that time my char set is not working not set so it gives junk values?.
0
 
objectsCommented:
> what kind of log i will put . before that i put System.out.println(System.getProperty("file.encoding"));

log the string value that is getting corrupted.

> new String (resultSet.getString(1).getBytes(),"UTF-8") if i use this that popup will coming like ?????? mark ??

theres no need to do that, just output the string directly
0
 
Sathish David Kumar NArchitectAuthor Commented:
>>>>>>>>> new String (resultSet.getString(1).getBytes(),"UTF-8") if i use this that popup will coming like ?????? mark ??

>>theres no need to do that, just output the string directly

I put the log (resultSet.getString(1))here the junk value are coming  but display in screen is perfect ??  is it log file problem ??
0
 
objectsCommented:
depends how are you viewing the log, you need to ensure whatever you are viewing it with has support for displaying japanese text
0
 
Sathish David Kumar NArchitectAuthor Commented:
No it not supporting ? i checked !
0
 
Sathish David Kumar NArchitectAuthor Commented:
org.displaytag.filter.ResponseOverrideFilter.init(ResponseOverrideFilter.java:108) - Filter initialized. Response buffering is enabled

i got this before its going to char set filter what kind of error is this ??
0
 
objectsCommented:
then use something else to view the log. assuming the log is a text file then you just need something that can view text files containing japanese.
0
 
objectsCommented:
> i got this before its going to char set filter what kind of error is this ??

don't believe that is an error
0
 
Sathish David Kumar NArchitectAuthor Commented:
sorry i wrongly pasted !!

org.apache.axis.configuration.EngineConfigurationFactoryServlet.getServerEngineConfig(EngineConfigurationFactoryServlet.java:162) - Unable to find config file.  Creating new servlet engine config file: /WEB-INF/server-config.wsdd

this is the error ?
0
 
objectsCommented:
its failing to find a wsdd, doubt thats related to your current problem
0
 
Sathish David Kumar NArchitectAuthor Commented:
lastly i found out .....

>>>>>>I didnt change anything its working fine in my pc . But i deployed the code in UAT  envi . its again give junk value ?  how thats posible ............

I didnt change server.xml file in deployement envi !!
0
 
objectsCommented:
from what you have posted the problem is not in server.xml
0
 
Sathish David Kumar NArchitectAuthor Commented:
Thanks again . Really i dont know how to tell you have spen lot of time with me .
0
 
CEHJCommented:
:)
0
 
leakim971PluritechnicianCommented:
You guys ROCK!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 44
  • 23
  • 22
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now