Stack Exchange
Long string from jsp javascript to servlet
I need to send some big string (5000 characters including '=' and '&'), dynamic array and short string to servlet.
<script type="text/javascript">
var categories= new Array();
var tit= document.getElementById("title");
var cont= document.getElementById("content");
</script>
<input type="text" id="title" style="width:250px"/>
<textarea id="content" style="width:400px"></textarea>

I thought to try xmlhttprequest with POST, but 'content' cotrol can contain '=' and '&'

Use JavaScript's encodeURIComponent(param) function:
Your case: You need to encode cont like the following encodeURIComponent(cont). This will escape '=' and '&' and other special chars.
For example
var url = 'http://myserver.com?content=' + encodeURIComponent(cont);


No. Server will automatically decode it. You will get original content at server site.
