0

I understand web service provides all SOAP,WSDL support, and it stands at a higher level than Servlet.But if I just simply wanted to expose a rest api to allow another application(client) to make a few very easy queries which can be done even via web browser.

eg. http://serverIP/getUserInfo/123 where 123 is like user's id. Let's just assume user info is returned as json.

Questions are: Is there a big difference between implementing it in Servlet and Jersey? If the client application is written in .net, does that make any difference? Is it true that jax-ws allows you to specify the MIME type to be json while servlet's client has to parse the result? From performance perspective, which one is quicker? I noticed that normally, Jersey is meant not to be deployed on Tomcat while Servlet is.

1

1 Answer 1

1

Is there a big difference between implementing it in Servlet and Jersey?

Jersey is a framework that makes it a lot easier to write Restfull services. It uses the Servlet API, so it abstracts away a lot of the low level stuff.

You have to write a lot more code doing it using only the Servlet API, and the code has to deal with a lot of low level stuff that you can configure in a declarative way using Jersey.

If the client application is written in .net, does that make any difference?

No

Is it true that jax-ws allows you to specify the MIME type to be json while servlet's client has to parse the result?

Jersey lets you declare the mime type using annotations, but that's only for convenience, you still have to parse the incoming payload to check for correct mime type.

From performance perspective, which one is quicker?

Depends if you are able to write a faster implementation than the Jersey team. Jersey use servlets as well.

I noticed that normally, Jersey is meant not to be deployed on Tomcat while Servlet is.

Tomcat is a servlet container. Jersey uses the servlet API to communicate over HTTP. There are web-frameworks that don't use servlets, for instance Play framework.

3
  • I would add that any performance difference between the implementations, are probably not noticeable, because the time to query a database is much higher than parsing or assembling JSON. @Shengjie in this respect don't worry about computer performance, rather, better worry about programmers performance.
    – stivlo
    Mar 17, 2012 at 16:26
  • Hey @ebaxt, until now I've been using Spring MVC to write web services, I've heard of Jersey, but didn't venture yet. I return objects from the controllers that are automatically converted to JSON by Jackson. Do you suggest me to pick up Jersey as well, or is a similar approach?
    – stivlo
    Mar 17, 2012 at 16:33
  • 1
    @stivlo In my experience the feature set in Spring MVC rest is pretty much the same as in Jersey, but if you want to use JSR-311 than Jersey is the way to go. Have a look at this comparison: infoq.com/articles/springmvc_jsx-rs
    – ebaxt
    Mar 17, 2012 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.