JSP syntax highlighting in IntelliJ IDEA Community Edition
By default, syntax highlighting for Java Server Page (JSP) does not work very well in IntelliJ IDEA Community Edition. Only a few HTML tags and CSS constructs are highlighted, while many Javascript contructs such as single line comments will just show up as normal text. HTML attributes are also not highlighted:
Interesting, if the JSP extension is removed from the JSP (Syntax Highlighting Only) type under Settings > Editor > File Types, syntax highlighting will suddenly become much better. Java codes, CSS and HTML are now correctly highlighted, for the most part:
This is the dialog where JSP syntax highlighting is configured for JSP. All file type have been removed from File Name Patterns:
Even JSTL construct such as <c:choose> or <c:when> are also properly highlighted. This feature is only officially available in the paid edition of IntelliJ IDEA:
At first I thought this was good enough for me. However, after a restart of the IDE, syntax highlighting once again became much more limited. Only strings and special characters were highlighted, with JSTL showing as normal text. I believe this is an IntelliJ bug:
I didn’t want to spend my hard earned money on the Ultimate edititon just for JSP syntax highlighting, so I decided to define my own file types for JSP, associating it with *.js?:
IntelliJ only allows four different keyword highlight colors, so I grouped the common JSP-related keywords into four categories:
- JSP Constructs
- Java Language
- HTML Markup
- JavaScript Code
I then configured these as Groups 1, 2, 3, and 4 in the dialog above. Since there was no dedicated space to add HTML comments like <!-- -->, I highlighted them separately instead. The result is the following editor screen, which is obviously not the best syntax highlighter down there, but definitely more than good enough for me:
Autocomplete is still limited to same-document word matching, which is better than nothing. Still, I am satisified with the results and will not purchase the Ultimate edition any time soon. The keyword list I used can be downloaded here for those who are interested.
See also
Enable syntax highlighting in Nano for Java Server Pages (JSP)






