0

http://s3.postimg.org/y8iueoh0z/file.jpg

When a user hits my web service, I want to return an html page. The html page is in the same folder as my landing page. I have tried a lot of different permutations on the file path using .getClassLoader().getResourceAsStream("assetToken.html"); but they are always null. I feel like the command is right but it just doesn't see the file. If I load the file using File and absolute path, the html page returns, but I get a bunch of 404s on not being able to load the dependencies of the html file(a few angular stuff).

From my photo I am trying to load the circled photo in my rest service(jersey). I am not too familiar with class path/ build path, but from my picture I can see the file I want to load is under deployed resources, which I assume is the class path or something?

gallly
  • 1,201
  • 4
  • 27
  • 45
  • I don't understand, why are you trying to load an HTML file as a stream in Java? Isn't it a web app? – Dave Newton Sep 14 '15 at 18:41
  • I read thats how you return an html page and jersey will handle it for you – gallly Sep 14 '15 at 18:41
  • Have you tried using getContext().getResourceAsStream(filename)?See also: http://stackoverflow.com/questions/1814517/get-servletcontext-on-tomcat-from-jax-rs-jersey – user Sep 14 '15 at 18:41
  • yes I have tried that and everything from /src to /src/main to /src/main/webapp – gallly Sep 14 '15 at 18:42
  • If you want to get the resource as a stream then it needs to be in your classpath, not in your web content. – Dave Newton Sep 14 '15 at 18:42
  • can you elaborate as I said I am new to the subject, I thought the classpath=webapp folder/webinf folder... and the image is in the webapp folder – gallly Sep 14 '15 at 19:05

0 Answers0