special characters in URL

Posted on 2005-02-24
Medium Priority
Last Modified: 2013-12-03

I am using iplanet webserver 6.0 and am reading requests from request object in servlets
string str = request.getParameter("parameter");

when i pass a string which has special characters like ėĕ I am getting bad values in the string.  I need to attach the strings like that in email and send it or store it in a flat file.
what is causing the the junk value to come into request object.  I know that the characters ėĕ are coming in as junk because when i try to print the ascii values of the characters ny type casting the characters to int it is printing values of 65565.  java is supposed to be uni code right?
AShok Pappu
Question by:ashokpappu
LVL 55

Expert Comment

by:Ryan Chong
ID: 13399459
You may need to decode your parameter, try see if this work?

string str = java.net.URLDecoder.decode("" + request.getParameter("parameter"),"UTF8");

Expert Comment

ID: 13400832
The & symbol is causing it to think it is a new variable being passed. You will need to urlencode the values and then urldecode them on the other end. The encoding iwll change the characters so they may be passed in a friendly manner.

Author Comment

ID: 13415835
I am sorry that the website(experts -exchange.com) has incorrectly interprited my example.

Let us say that in the word entrie (french) (i.e letter e with a style cap on top ') is typed on the browser page and submitted to the website. it is coming in as some character which is unreadable the ascii value is some thing around 65536.  I don't know how or why.  This is simple text there are no &# as the website (experts-exchange.com) interprets french characters.  

Let us say that some one has typed a email in french and clicked submit button on the web page.  When i do request.getParameter("emailBody")  and print the string return value with a log(request.getParameter("emailBody").  Where ever there are french characters there is junk. when i try to write this to a file it is being displayed as ???.  do i need to convert the string to any other format.  
please advise.

LVL 11

Accepted Solution

JohnModig earned 252 total points
ID: 13418653
In your form, change action="get" to action="post" and then do request.form("field") instead.
Then you do not have to deal with how your browser interpet the special characters.

Assisted Solution

CrashRoX earned 248 total points
ID: 13427482
JohnModig is right, you should request email content as a get. For one it will limit the available size of the passed data. Its a bit more insecure. Thirdly its causing those character letters.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

571 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