This week's book giveaway is in the NodeJS forum. We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line! See this thread for details.
I have a confusion regarding "Web Services",
Assume there is an 'Employee Management Web application'.
You have to perform a task that is to display all the records of employees from 'Employee' table.
you have written an 'EmployeeController' class where you are returning the "List" of employee objects to the browser through ModelAndView object, you even mentioned the "view" page name as well:
Now here it leaves me confused....the below written RESTful WS method performs the same task what the above method does but it sends the Employees objects in JSON format.
I want to know when does the above method has to execute and when this below one?
How relevant are both to each other? Does every java based web project contains both types of methods for a particular operations?
I hope you have understood what i want to ask. Your help will be much appreciated. Thanks!
I suspect that this codereturns object list named "employees" for the view named "page".
This view would most likely generate some document (often HTML or PDF) and a listing of objects as created by the view and template engine.
"/show/allEmployees" is the data rendered and ready for immediate presentation (usually via web browser) thanks to the logic provided by the view.
However this code:only returns the data without any extra markup. This data is most likely returned at a listing of JSON or XML objects.
The "allEmployees" call is a REST call which would be consumed by another program, maybe IOS, Android etc. This is only the data and nothing but the data.
Usually the consuming program has to add some extra display elements/design to the data before being displayed.
They are related in that they provide the same information, but in different ways for the consuming client.
Arun Singh Raaj wrote:Does every java based web project contains both types of methods for a particular operations?
No, as there is not always a reason do. Some data should not be consumed via REST for business reasons or other reasons.
Often most only program what they have to and nothing else. So you may see REST data or you may just regular data or you may see both.
Depends on what the project needs to provide to the end users/consumers.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
It depends heavily on whether your application's presentation layer is mostly in the client or in the server.
For instance, it's possible to have an application that consists of a lot of static HTML pages, and every time you make a request the server builds a new web page. In this case, your server will mostly have methods of the first kind, that return a ModelAndView.
The other extreme is an application that consists of a single dynamic web page. In this case, the server has one method that returns a ModelAndView containing the entire client-side application, and all interaction with the server is done through AJAX requests that get handled by methods of the second kind, that return a JSON response body.
Most web applications are somewhere in the middle. They host a couple of different HTML pages, which to a varying degree communicate with the server with AJAX request.
Arun Singh Raaj
posted 1 year ago
Thank you for clearing that up... Stephan van Hulst, Pete Letkeman.
I like tacos! And this tiny ad:
global solutions you can do in your home or backyard