2

I have a JSP file that consists of two <%@ include ... lines and a scriptlet, nothing else. The file ends with the scriplet closing %>, and no new line. The file compiles and is served by Tomcat as expected.

If I add a new line to the end of the file (more precisely, when Emacs does it automatically after I edit the file), the page produces a 500 error "Unable to compile class" with the specific complaint that the final line (now effectively %>\n) is "unreachable code".

I've gone back-and-forth in multiple editors, and I'm certain that the only difference between functioning and non-functioning files is the presence of the new line at the end of the file. I've searched, and I can't find any discussion of this kind of problem. Why does the closing newline break Java/Tomcat in this instance?

PiotrChernin
  • 441
  • 8
  • 18
  • 1
    Could be a conflict between emacs line ending (LF only) and what Tomcat might be expecting (CR + LF). [This](https://stackoverflow.com/questions/9760290/emacs-change-default-line-ending) might help. – Andrew S Feb 05 '18 at 17:26
  • Please show your JSP file. – P_M Feb 05 '18 at 18:26
  • @AndrewS A good suggestion, but I don't think that's it. Among other reasons, if I add a carriage return explicitly to the end of the file before the newline, Java compilation still breaks. – PiotrChernin Feb 05 '18 at 19:26

0 Answers0