If you're looking to return dynamic HTML, you're probably better off using an MVC framework (like Spring MVC), rather than a REST framework. If you want to stick with using the same REST Framework you are using, if you are using Jersey, Jersey has MVC Support
The general idea of how MVC frameworks work, is by using templates and controllers to populate models used in the templates. In pseudo code, you might have something like
template (index.html)
<html>
<body>
<h1>Hello {{ name }}</h1>
</body>
<html>
controller method
public Viewable index() {
Map<String, String> model = new HashMap<>()
model.put("name", "Peeskillet");
return new Viewable("index", model);
}
This is example code that you might use with Jersey (and its MVC support), but using Spring MVC, the concept would still apply, just the classes used would be different.
The basic concept is that you fill the model inside the controller, and tell the framework which template should be used. The framework will take the template, and inject the variables wherever you request them, and then return the converted view to the client.
You should decide on which framework you want to use and read the documentation linked to above for more details. Spring MVC was made specifically as an MVC framework, where Jersey is a REST framework that added MVC support as an afterthought. So you will get more features with Spring MVC. But for basic MVC functionality, using Jersey would work.
As an aside, if you are already coming from an MVC framework (like Spring MVC) background, then you need to shift your thinking a little bit. With REST API (or web services as you call it), normally you won't be sending HTML page responses. Normally it will be a lighter weight data format like JSON. If you are creating a web application that interacts with the REST API, you would normally using AJAX (Javascript) to request the JSON, and it use the JSON data to update the DOM. That's generally how it works.
FileInputStream