I am building a simple REST service to fetch some data and then show it. Very basic so far. I am using a jersey/tomcat combination, build with Maven.
Everything goes well, except for the fact that I want to add some css and perhaps in a later stadium jquery to the webpages. Because of the simplicity, I have coded my resource like this:
@Path("/home")
public class Home {
@GET
@Produces("text/html")
public String getStatus(){
String html = "<!DOCTYPE html><html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/css/style.css\"> </head><body><h1>status!</h1>normal text</body></html>";
return html;
}
}
This is a very simple example, but I have no clue as to where I should put the 'style.css' file.
I have been searching the web, and some people suggest that I should create a webapp folder and put the files in there, but not under the WEB-INF folder (which will automatically be put in the webapp folder). But that doesn't really help. I created the folder by adding this in my POM:
<resource>
<directory>${basedir}/webapp</directory>
</resource>
Other suggestions were mainly directed at using .jsp files, but I dont want to use those. I want to keep it as simple and straightforward as possible.
So basically the question is: how do I enable CSS to that kind of jersey response?
On a sidenote: The only reason I want to return hardcoded html the way I do now, is because it is simple. But I find it an ugly way. Is there a more flexible way to do this without the use of .jsp files?