Summary
The issue is IntelliJ IDEA not recognizing standard JSP tag libraries—highlighting taglib URLs and tag names as errors, and stripping code completion—even though the application works correctly on Tomcat. This is almost always a IDE configuration problem: missing or corrupted taglib imports, invalid project structure, or an out‑of‑sync JDK/library configuration.
Root Cause
-
Invalid or missing
<%@ taglib %>imports
The IDE cannot resolve taglib URIs if the corresponding tag library descriptor files (*.tld) are not on the classpath or the JAR that contains them is not indexed. -
Project SDK / Facets mis‑configured
When the project facets are set to the wrong language level or the “Web”‑facet is missing, IntelliJ does not load JSP support. -
Cached indices corrupted
The local index may have become stale after upgrading IDEA or changing the project layout, causing the IDE to misidentify tag names. -
Wrong module dependencies
Tag libraries present in one module are not visible to another if module dependencies are incorrect.
Why This Happens in Real Systems
- Rapid library upgrades – Adding/removing servlet containers or refactoring modules often leaves IDE indices out of sync.
- Manual configuration changes – Switching JDKs, moving
WEB-INF/libdirectories, or enabling/disabling facets without re‑indexing. - Multi‑module projects – Tag libraries defined in one module are required in another, but the dependency chain is incomplete.
Real-World Impact
- Reduced developer productivity – Missing auto‑completion forces manual typing and increases the chance of typos.
- Increased bugs – Unvalidated JSP tags can slip into code where real mistakes (wrong attribute names, missing dependencies) would otherwise be caught by the IDE.
- Hampers onboarding – New developers face confusion when the editor marks perfectly valid JSP code as errors.
Example or Code
Below is the typical taglib declaration causing the error:
IntelliJ also needs the proper JSTL JAR (e.g., jstl-1.2.jar) on the module’s classpath.
How Senior Engineers Fix It
-
Verify the JARs in
WEB-INF/lib- Ensure
jstl-1.2.jar(or the correct version) is present and added as a dependency in the module.
- Ensure
-
Check Project Facets
- File → Project Structure → Facets
- Enable Web facet and set the correct Supported Facets (JSP, JSTL).
-
Align SDK & Language Level
- Project Structure → Project → SDK set to the JDK used by Tomcat.
- Modules → Dependencies → Make sure the module uses the same SDK.
-
Re‑index the Project
- File → Invalidate Caches / Restart… → Invalidate and Restart.
- This forces IntelliJ to rebuild taglib indices.
-
Explicitly map the URI
- In Settings → Editor → General → Smart Keys → JSP add a custom taglib mapping if necessary:
http://java.sun.com/jsp/jstl/core => lib/jstl-1.2.jar
- In Settings → Editor → General → Smart Keys → JSP add a custom taglib mapping if necessary:
-
Confirm module dependencies
- Modules → Dependencies → Add the module that holds the JSP tag libraries if they are split across modules.
After these steps, the editor successfully resolves <c:if>, offers code completion, and removes erroneous warnings.
Why Juniors Miss It
- Assuming IDE errors are code errors – New developers often check the source instead of the IDE configuration.
- Not understanding facets – They overlook the Web facet and think all web libraries are auto‑included.
- Skipping cache invalidation – They forget to restart IDEA after moving files or updating libraries.
- Underestimating module boundaries – They assume all libraries are globally visible without setting proper module dependencies.
By mastering the project structure settings and understanding how IntelliJ indexes tag libraries, senior engineers keep the IDE in sync with the runtime environment, preventing this frustration.