This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to handle '&' in a parameter value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to handle Watch "How to handle New topic

How to handle '&' in a parameter value

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146

I am using AJAX to save a name value. This is my JS code in the JSP file:

In my servlet I simply extract the parameters and use them:

This works fine until user gives name like 'This & That' (anything that has an '&'). When this happens the servlet gets only the string before & (eg. 'This ')
This is happening because it thinks that there is another parameter due to occurrence of &.

Using & doesn't work too, because & comes there also.

Can someone please suggest how can I work around this?

Thanks in advance
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
check this link

may be help you.

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
That worked Shailesh.

Thanks very much.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63052

Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: How to handle '&' in a parameter value
It's not a secret anymore!