GeeCON Prague 2014*
The moose likes Web Services and the fly likes Servlet JSON response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Servlet JSON response " Watch "Servlet JSON response " New topic
Author

Servlet JSON response

leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
I'm just asking for the sake of clarity, but if a servlet returns a varying JSON response, does that make it a web service?

Ex: http://somehost/xyzservlet?param1=foo&param2=bar

Varying param1 and param2 can yield different JSON responses. Is this considered a "web service"?


Thanks, leo
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

I guess that greatly depends upon how you define "web service"?

I'll move this over to the web services forum for any further discussion.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

For what it's worth, a large number of the servlets in my current project return JSON, as the app is heavily Ajax-ified. I do not consider these servlets part of any "web service".

(We do have a RESTful web service for the system -- but it's XML-based.)
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Just curious to see what people thought.

Do most people create their own process for converting Java HashMap Objects to JSON or do they use existing code such as: www.json.org/java ?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Personally, I have always used different kinds of libraries to help me with marshalling and unmarshalling JSON data. My favourite library is Jackson: http://jackson.codehaus.org/
Best wishes!
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Is this considered a "web service"?

http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=Phoenix%20Arizonat&results=10

It returns XML. My idea of a servlet returning a JSON string is not much different.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

I use Google's gson library for JSON conversions.
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
google's gson worked the first time I passed a plain old Java object.
 
GeeCON Prague 2014
 
subject: Servlet JSON response