Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP and URL encoding

843833Nov 6 2001 — edited Nov 6 2001
Whats the best way to url encode input fields when processing form fields. Tried using this:
function replacechar(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text)
var newstr = ""
if ((!i) || (i == -1))
return string;
newstr = newstr + string.substr(0,i) + by
if (i+text.length < string.length)
newstr = newstr + replacechar(string.substr(i+text.length,string.length),text,by);
alert("test = " + newstr)
return newstr;
}
invoked by using this:
<%usertask=replacechar(usertask," ","%20")%>
as a java script function in my jsp but I get servlet errors. Should I create a class and access it using 'usebean' to do the conversion or is there a shortcut method I can use directly in my jsp. Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2001
Added on Nov 6 2001
1 comment
243 views