I am writing a REST service providing 2 things:
1. Data information (which are read from a database)
2. A web-application (i.e. a webpage)
So currently I only have an index page and I return this html file in a REST request. My Service class for this looks like that:
@Path("web")
public class MainPages {
@GET
@Produces(MediaType.TEXT_HTML)
public InputStream getIndex(){
File index = new File("webapp/pages/index.html");
try {
return new FileInputStream(index);
} catch (FileNotFoundException e) {
String s = "ERROR";
return new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
}
}
Now in the HTML file I try to include some javascript file which is placed in the same folder as the HTML file. The header of the HTML file looks like this:
<html ng-app>
<head>
<meta charset="utf8" />
<title>Welcome</title>
<script type="text/javascript" src="angular.js"></script>
</head>
The problem I am facing now is, that the src is not getting the file but instead the REST Service is activated, as you can see in this image:
I think I am missing some important information here.
But my question is: How can I tell the page to look in the folder and not to request the file from the REST?
Or do I need to add the corresponding Path to the REST Service and return the javascript file there?