0

I have a Java script that should call and pass parameters servlet using url encoding. The java script gets the parameters from the html form. I have done this and validated the input. I'm not sure how to encode the url in java script.

The parameters are title=XXXX and type=YYYY. The servlet url is www.xxxx:Port#/folder/servlet. I have the code in place to retrieve the parameters from the url in servlet. I'd like to know how exactly to build the url using url encoding.

Further more the Javaservlet should retrieve the parameters and call a perl function. Again here url encoding is to be used.I'd appreciate any help here.

Trozan
  • 89
  • 2
  • 11

1 Answers1

0

Look on this answer: Encode URL in JavaScript?
Example:

var myOtherUrl = 
       "http://example.com/index.html?url=" + encodeURIComponent(myUrl);
Community
  • 1
  • 1
Naor
  • 23,465
  • 48
  • 152
  • 268
  • Please read http://w3fools.com then read the comment at the site you should to point at: [MDN](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Functions?redirectlocale=en-US&redirectslug=Core_JavaScript_1.5_Guide%2FFunctions#escape_and_unescape_functions) that escape is deprecated,although it is rare to see non-ascii in URLs – mplungjan Nov 18 '12 at 06:38