Convert JSON Object to String javascript
You can user browser native function JSON.stringify to do this
var foo = {};
foo.bar = "new property";
foo.baz = 3;
var jsonString = JSON.stringify(foo);
https://developer.mozilla.org/En/Using_JSON_in_Firefox
And IE8 also supports it - http://blogs.msdn.com/b/ie/archive/2008/09/10/native-json-in-ie8.aspx
jQuery Template plugin html in variables
If you pass html content in the template variables, you have to use format to make sure that the html content gets converted into real html elements.
See this Stack overflow post http://stackoverflow.com/questions/4570222/htmlentities-equivalent-in-jquery-template-plugin
And this documentation - http://api.jquery.com/template-tag-html/
Javascript code equivalent to java i18n MessageFormat
Here is a Stack overflow post with javascript regex solution for this problem.
How to center a div inside a div
If you need to center a div within another div, here is the solution from Stack overflow post -
http://stackoverflow.com/questions/114543/how-to-center-div-in-div
Quoting example from the post below for quick reference,
<div id="outer">
<div id="inner">Foo foo</div>
</div>
#inner {
width: 50%;
margin: 0 auto;
}
Handling cookies with java URLConnection
http://www.hccp.org/java-net-cookie-how-to.html
Same way you can set other headers like Content-Type, Accept to the HTTP request using the setRequestProperty method of URLConnection