Solved

how to pass the japnesh  char to URL

Posted on 2011-03-09
92
431 Views
Last Modified: 2012-05-11

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
Comment
  • 44
  • 23
  • 22
  • +1
92 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082063
Please post your current code
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082069
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35082133
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 35082231
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35082344
Same result no change !! :(
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082354
What exactly is the result?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35082355
Do you have a live link to have a look to your page ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082396
Please past the result of

alert(uri);

here
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35082451
check
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082543
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
 
LVL 82

Expert Comment

by:leakim971
ID: 35082567
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35082619
So this URL Parameter i will get the value in the java (request.getParameter()) its giv junk value....
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35082687
check
check this image . right side is parent window  and left side is popoup window the value is not set !  check
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082710
What does the below give on your struts host vm?


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

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35082803
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35083010
>>>>>>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35083228
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35083298
s its display properly .
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35083726
Please also post (pref as attachment) the source code of that page you pictured
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35083776
which one ?
popup or parent ?  
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35083810
Both would be good
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35083868
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35083882
do you need full JSP ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35084023
Yes, that would be best. Attach as text file please
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35084137
x.txt parent
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35084182
CHild
x.txt
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35084938
Take a close look at the filter - it might not be getting called (put some debug in it)
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35085165
do u want that filter code ?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 35088464
you need to make sure your container is configured to use UTF8
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35091047
how to ensure that ?

container is configer with UTF-8 format ?
0
 
LVL 92

Expert Comment

by:objects
ID: 35091078
what container r u using?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35091112
Servlet 2.4
0
 
LVL 92

Expert Comment

by:objects
ID: 35091171
are you using tomcat?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35091207
S tomcat only .
i set that value in server.xml also
0
 
LVL 92

Expert Comment

by:objects
ID: 35091273
post your server.xml and I'll check it
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35091448
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35091488
URIEncoding="UTF-8" i set like this in port 8080
0
 
LVL 92

Expert Comment

by:objects
ID: 35091842
then where do you get the parameter value from the request?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35092129
In my action (java) class .only
0
 
LVL 92

Expert Comment

by:objects
ID: 35092269
can you post that code.
and where you then pass the value to the page for rendering
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35092428
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35092445
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
 
LVL 92

Expert Comment

by:objects
ID: 35092534
> 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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35092643
>>>>>>>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
 
LVL 92

Expert Comment

by:objects
ID: 35092768
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35092914
>>>>>>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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 92

Expert Comment

by:objects
ID: 35093047
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35093339
I thought it was info from the form that was corrupt, not db stuff dravidnsr?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35095586
>>>> 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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35095615
>>>>>> 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
 
LVL 92

Expert Comment

by:objects
ID: 35100833
> K how can i correct that ?

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

0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35111722
Any other input ??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35111739
I'm still waiting for you to answer my question...
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35111797
which one??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35112129
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35114707
>>>>>>>>>>>>>>> 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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35114711
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
 
LVL 92

Expert Comment

by:objects
ID: 35114712
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
 
LVL 92

Expert Comment

by:objects
ID: 35114724
> 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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35114744
>>>>>>>>>>>>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
 
LVL 92

Expert Comment

by:objects
ID: 35114775
> 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
 
LVL 92

Expert Comment

by:objects
ID: 35114777
> Two boxs means ?

sorry, I meant the two computers Dev and UAT
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35115042
Please verify that you deployed the filter to UAT and that it's being called
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35128912
my ant bulider have encoding format as ISO is that effect the code ??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35129597
>>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
 
LVL 92

Expert Comment

by:objects
ID: 35132926
> my ant bulider have encoding format as ISO is that effect the code ??

where is it using ISO?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35135455
>>>>>>>>>
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
 
LVL 92

Expert Comment

by:objects
ID: 35135469
thats fine :)
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35137877
>>>>>>>>>
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35138363
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35139421
What you should do is limit the possible input values to as few as possible - preferably one only. Is that possible?
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35140478
ya its only one not more than that !! (its search screen and fetch only one value )
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35140612
Please show (in Unicode escaped format) what the value of the field should be, e.g.


\u20ac\u1159
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35140978
which one??
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35140993
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35141061
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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35141148
>>>>>>>>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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35141276
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
 
LVL 92

Expert Comment

by:objects
ID: 35142444
> 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
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35144593
>>>>>>>>> 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
 
LVL 92

Expert Comment

by:objects
ID: 35144626
depends how are you viewing the log, you need to ensure whatever you are viewing it with has support for displaying japanese text
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35144671
No it not supporting ? i checked !
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35144683
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
 
LVL 92

Expert Comment

by:objects
ID: 35144695
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
 
LVL 92

Expert Comment

by:objects
ID: 35144706
> i got this before its going to char set filter what kind of error is this ??

don't believe that is an error
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35144767
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
 
LVL 92

Expert Comment

by:objects
ID: 35144776
its failing to find a wsdd, doubt thats related to your current problem
0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 35144983
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
 
LVL 92

Expert Comment

by:objects
ID: 35145000
from what you have posted the problem is not in server.xml
0
 
LVL 20

Author Closing Comment

by:Sathish David Kumar N
ID: 35145203
Thanks again . Really i dont know how to tell you have spen lot of time with me .
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35145850
:)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35147310
You guys ROCK!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now