This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes JSON At in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "JSON At in servlet" Watch "JSON At in servlet" New topic

JSON At in servlet

Sonu Sen

Joined: Jun 03, 2009
Posts: 17

I am generating a JSON String at client side that is in JSP page and send to the server means to servlet. And I catch that string in the servlet using getParameter(). But I cant access the single element from that JSON string in the servlet.Please tell me How can servlet reterive the single element from the String.

Eg. {"Iem1":"3","Item2":"4","Item3":"12"}

then I want only 3. How can I get that 3.
Guogang Fan

Joined: Aug 17, 2009
Posts: 7
you can parse the String yourself with those String functions defined in java.lang.String.
or you can use some Java library to do it
www.json.orghave introduced many java api to handle json .
Guogang Fan

Joined: Aug 17, 2009
Posts: 7
you can also parse the Json String at client side then send the server what you need.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61308

Why are you creating a JSON string at all if that's not what you need?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
GeeCON Prague 2014
subject: JSON At in servlet