I suspect that this code
returns 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.