Preface: I am an inexperienced java programmer handed one of his first assignments. If I do not ask the question correctly or do not give enough detail, please let me know.
I am trying to import a HTML page that is saved on my C drive. I am trying to import it to the content portion (div id=”content”) of a JSP file that exists in a war file. I have already figured out that I can not use jsp:include, #include, @include file because the file exists outside the war file. I also figured out that c:import and iFrame do not work.
My goal is to make the contents of the html file that is saved in on my c drive appear in the contents of the jsp (visible on the web page).
Am I on the right track with this <% File f = new File("c:\\temp\\filename.html").......%>
I have searched stackoverflow and the only topic that came close was “How to Include a file outside the application (war) using jsp include.” It did not really get me where I needed to go. Maybe the answer is right in front of me but I couldnt see it.
JSP/JSTL does not offer tags which support this. You’d need to do it using pure Java. You just have to write it to the response yourself.
Here’s one of the simplest ways:
You could wrap it in a custom tag to keep your JSP free of scriptlet clutter, or you could read it into a
Stringin a servlet and pass it to JSP EL scope.