tags:

views:

39

answers:

2

How do I use JSON in java servlet? Using the URL, to pass parameters from a POST servlet, the JSON would respond based on the URL parameters.

A: 

"How do you use it"?

JSON is simply one way of representing hierarchical data (such an an object model) in a flat text format (such as an HTTP body, or filesystem file). So you'd use it to represent hierarchical data in these situations.

If you mean how do you parse/create it, there are many mature libraries for JSON handling.

Perhaps a specific situation or use case would assist in pinning down your question, if the above is not the answer you were looking for.

Andrzej Doyle
How do I pass parameters from ServletOne to ServletTwo using a HTTP POST through URL intead of using HTTP GET in the servlet? For example: http://localhost/ServletOne?username=testIf the above link is accessed, in ServletTwo, username test will be displayed.
+1  A: 

You need a JSON library in Java. With that library, you will be able to serialize Java Objects into JSON objects, and send them through HttpServletResponse instance in your Servlet.

Pablo Santa Cruz