need to escape names with apostrophe

I have a jap which has an hyperlink and upon clicking that hyperlink calls a javascript method.
There are 5  parameters inside javascript function. and one of the parameters is a string lastname

In scenarios where  a lastname has an apostrophe in them example L'Esperance while calling a javascript function ,this apostrophe acts like an end of function and doesnt call the javascript function and displays javascript "error on page"

I need to escape names with apostrophe  in them.

Here is my chunck of code where its calling javascript function

<html:link href="javascript:somefunction('${someVO.context}', '${rsoeVO.displayType}', 'true', '${guestInformationVO.lastName}', '${rsomeVO.confirmationNumber}');">
      click here      </html:link>

${guestInformationDisplayVO.lastName} gives L'Esperance

I need to remove the apostrophe from this:  ${guestInformationDisplayVO.lastName}

I tried to use javascript:escape(${guestInformationDisplayVO.lastName}) ..but didnt work

anyhelp would be great


pacchureddyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

suprapto45Commented:
Hi,

Can't you escape it from your Java app when you are storing the value into guestInformationVO?

David
0
suprapto45Commented:
I mean from your Java codes ;)

David
0
pacchureddyAuthor Commented:

I dont want to remove the apostrophe completly from lastnames . Only when calling this javascript function  I want to escape the apostrophe .so the call to the javascript function is made.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

actonwangCommented:
hi,pacchureddy,

        You can simply  use jstl1.1 bulit-in function fn:replace as the following:
         
        ${fn:replace(guestInformationVO.lastName,"'"," ")}

        L'Espe will become   L Espe.

        You can also provide different substition for  apostrophe.      

Enjoy      

Acton
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
actonwangCommented:
if you want to avoid jstl (most of people will like it though :), then you have to create your own version of el function as fn:replace then use it in your el expression.

Acton
0
TimYatesCommented:
You can use:

    java.net.URLEncoder.encode( guestInformationVO.lastName, "UTF8" )

then use:

   unescape( param )

in the javascript method

To use it in a tag, you can use the Jakarta string taglib:  http://jakarta.apache.org/taglibs/doc/string-doc/string-1.1.0/index.html#encodeUrl

Tim
0
astrohelpCommented:
I am just curious why you are using their last name instead of some type of ID, I realize this is not a solution to your problem, but as I said, just curious.
0
suprapto45Commented:
Nope,

>>"I dont want to remove the apostrophe completly from lastnames "
You can embed the "\" escape character in your Java codes. So you got to check whether the last name contains any apostrophe. If so, you have to add the "\". Hence L'Espe becomes L\'Espe

Thanks
David
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.