0

I am trying to create a WebServices REST project with IntelliJ IDEA. The idea is to supply some files to the user, but it seems that I can't find them in Tomcat's directory. For now I am trying to serve just a simple index.html page, but Java reports that the file could not be found. My current project structure is this:

project structure

I thought that any data should be in the WEB-INF folder, or have I put it in the wrong place? Also, this is my GET function with the class I'm using:

enter image description here

Any idea what I am missing?

Ivan Stanev
  • 133
  • 1
  • 11
  • I can't tell how you're doing your mapping, but the file is located under the servlet context root, not relative to the working directory of your web app. – Dave Newton Feb 08 '16 at 19:51
  • I'm still learning how to do this, however my final aim is to have a personal REST server that I can perform tests on. As for the context root, how can I access that, or move the files there? – Ivan Stanev Feb 08 '16 at 19:54
  • Share the url, u r trying to hit and also you have not mapped your url with the function, you need to use @ Path annotation – abdulrafique Feb 08 '16 at 19:56
  • I am hitting http://localhost:9998/ , the path is @Path("/") , which is specified at the beginning of the class name. This class has only one method, loadHTML(), the one I posted above. I probably should have screenshot the whole class so it doesn't confuse you, will edit the post. – Ivan Stanev Feb 08 '16 at 19:58
  • 1
    http://stackoverflow.com/q/12160639/438992 But again, you're doing a lot of manual work that doesn't really seem necessary. – Dave Newton Feb 08 '16 at 20:04
  • Thank you for the link, fixed it now! I am still toying with this and I am a complete beginner, so what part of the code seems unnecessary? – Ivan Stanev Feb 08 '16 at 21:16
  • 1
    You're doing everything the hard way. Try following this tutorial: https://spring.io/guides/gs/rest-service/ – Software Engineer Feb 09 '16 at 08:57
  • @EngineerDollery Thank you! If I am using an Android application, would I add the Spring for Android dependency in Gradle, and then build a Spring REST client with it? – Ivan Stanev Feb 09 '16 at 11:56
  • 1
    The rest server has nothing to do with the android client and doesn't need to know anything about it at all, so don't add spring for android to the server component at all. – Software Engineer Feb 10 '16 at 12:32

0 Answers0