Link to home
Start Free TrialLog in
Avatar of Sathish David  Kumar N
Sathish David Kumar NFlag for India

asked on

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 ?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Please post your current code
Avatar of Sathish David  Kumar N

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Same result no change !! :(
What exactly is the result?
Do you have a live link to have a look to your page ?
Please past the result of

alert(uri);

here
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?
So this URL Parameter i will get the value in the java (request.getParameter()) its giv junk value....
User generated image
check this image . right side is parent window  and left side is popoup window the value is not set !  User generated image
What does the below give on your struts host vm?


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

Open in new window

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
>>>>>>>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?
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?
s its display properly .
Please also post (pref as attachment) the source code of that page you pictured
which one ?
popup or parent ?  
Both would be good
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

do you need full JSP ?
Yes, that would be best. Attach as text file please
Take a close look at the filter - it might not be getting called (put some debug in it)
do u want that filter code ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
how to ensure that ?

container is configer with UTF-8 format ?
what container r u using?
Servlet 2.4
are you using tomcat?
S tomcat only .
i set that value in server.xml also
post your server.xml and I'll check it
URIEncoding="UTF-8" i set like this in port 8080
then where do you get the parameter value from the request?
In my action (java) class .only
can you post that code.
and where you then pass the value to the page for rendering
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 ?
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

> 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
>>>>>>>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

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
>>>>>>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 ??

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
I thought it was info from the form that was corrupt, not db stuff dravidnsr?
>>>> 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 ?
>>>>>> 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?
> K how can i correct that ?

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

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

How can i know that form corrupt or not ?
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 ............
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
> 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
>>>>>>>>>>>>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
> 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 ....
> Two boxs means ?

sorry, I meant the two computers Dev and UAT
Please verify that you deployed the filter to UAT and that it's being called
my ant bulider have encoding format as ISO is that effect the code ??
>>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
> my ant bulider have encoding format as ISO is that effect the code ??

where is it using ISO?
>>>>>>>>>
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=".">
thats fine :)
>>>>>>>>>
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 !!
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 ?
What you should do is limit the possible input values to as few as possible - preferably one only. Is that possible?
ya its only one not more than that !! (its search screen and fetch only one value )
Please show (in Unicode escaped format) what the value of the field should be, e.g.


\u20ac\u1159
which one??
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)
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??
>>>>>>>>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
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?.
> 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
>>>>>>>>> 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 ??
depends how are you viewing the log, you need to ensure whatever you are viewing it with has support for displaying japanese text
No it not supporting ? i checked !
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 ??
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.
> i got this before its going to char set filter what kind of error is this ??

don't believe that is an error
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 ?
its failing to find a wsdd, doubt thats related to your current problem
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 !!
from what you have posted the problem is not in server.xml
Thanks again . Really i dont know how to tell you have spen lot of time with me .
:)
You guys ROCK!