1

So I have a Java Web Project in Eclipse - it's just eight files that I export as a WAR, and when I deploy it to Tomcat as a standalone app, with no 'include' statements, it works just fine.

The issue is that this webapp is destined to integrate into an existing website, which was not developed by me - this is a problem because I need to import files that will be present at run time, but which Eclipse freaks out about because it can't find them in this project.

For example, to give my app the site-wide header, I tried to use:

<%@ include file="../includes/head_section.html" %>

But Eclipse says no. Specifically it says:

Fragment "includes/head_section.html" was not found at expected path /my_project/WebContent/includes/head_section.html

How can I tell Eclipse to relax - the file will be there when you're loaded, the world is bigger than this particular webapp?

I have tried all plausible path combinations (omitting the '..', adding a '/' at the start, adding more ../../../s), and also tried giving it the external URL of the header file (though I didn't really expect that to work). I've also looked through the app/Eclipse settings, but I'm still kind of new to Eclipse and there's a lot to process there.

Thanks for any help - as always feel free to tell me if I haven't provided enough information. I'm using Eclipse for Java EE, on Ubuntu.

Sam Ireland
  • 512
  • 4
  • 20
  • 1
    Have you considered the possibility that Eclipse is in fact not "freaking out", but it is correct and what you expect is going to work is in fact not going to work at all? Have you looked at the documentation of the include directive to see how it works (and how it will not work)? Of interest: http://stackoverflow.com/questions/9110148/include-another-jsp-file – Gimby Oct 21 '15 at 09:04

1 Answers1

0

So in the end I had to solve this by writing a method to physically open a file and return the text inside.

Using <jsp:include... /> instead of <%@ include .. %> did not solve the problem (which I think is what Gimby was getting at with the linked question - apologies if this question is a duplicate), and nor did simply telling Eclipse not to ignore the error (there is still a 500 error when I try to load the page).

My solution is problematic in that it can really only work with static files, whereas I believe the jsp:include dynamic import would execute any JSP - but my immediate problem has been solved in this way.

Sam Ireland
  • 512
  • 4
  • 20
  • My immediate hint was towards you stopping to blame the tools and starting to blame your method of implementation. Everything you describe here sounds to me like the concept of portlets. https://en.wikipedia.org/wiki/Portlet – Gimby Oct 21 '15 at 15:44
  • I didn't mean to imply that I was blaming eclipse - I know there's a perfectly good reason why it doesn't let you statically import an external file. Thanks for the link - I haven't come across this concept before. – Sam Ireland Oct 21 '15 at 15:46