• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet JSON response

 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Google's gson library for JSON conversions.
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
google's gson worked the first time I passed a plain old Java object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic