Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

spring in action -rest

 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.manning.com/walls4/excerpt_contents.html

Here the toc says there is a section - writing resource oriented contollers. why do we need this when we have jax-rs classes ?
 
author
Posts: 396
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pradeep bhatt wrote:why do we need this when we have jax-rs classes ?



I don't suppose you necessarily *need* it. In fact, Spring MVC's REST model isn't dramatically different than JAX-RS. But one thing I can do with Spring MVC that I don't think I can do with JAX-RS (correct me if I'm wrong) is develop a website that serves resources, regardless of what representation the client wants them. What I mean by that is that I can write a Spring MVC controller that serves a Product resource (for instance) and it will be served as XML to clients asking for XML, as JSON to clients asking for JSON and as HTML/PDF/etc to clients (such as web browsers) asking for those formats on behalf of their human users. Same resource...same controller...same everything, except that the proper representation is chosen based on what the client asks for. I'm sure JAX-RS can do something along those lines, but I'm not sure about the human aspect of it (again, correct me if I'm wrong).

Also, even though the programming models are quite similar, I find comfort in knowing that my web development skills that I gained while developing human-facing websites with Spring MVC carry over to developing machine-facing web resources.
 
Pradeep bhatt
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig.

I found this link where JAX-RS Resource class can server the format based on the input accept headers.
http://publib.boulder.ibm.com/infocenter/wasinfo/beta/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Ftwbs_jaxrs_contentnegotiation.html

Let me know if I got you wrong.

I have read your books Spring in Action -1 and Xdoclet in Action and found them to be excellent. Please keep up good work. Hope to read your new edition on Spring soon.
 
    Bookmark Topic Watch Topic
  • New Topic