As the title says, I’ve encountered an issue where not a single <%@ directive attribute is being even recognised in any jsp files on VSCode.
For example something like <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
doesnt work, or <%@page import="java.util.ArrayList" %>
. Basically, anything with <%@ doesnt work, < just gets colored with red. Universal issue, happens with all Java projects.
The syntax is correct, I have the right Maven Dependencies installed, jstl-1.2 . I tried installing VSCode on a seperate computer, and even there I have the same issue, the < is just marked with red and the lines just show up as "?" in the outline. This happens with any Java project, mine or even my teacher’s example code. And since taglib is not working, neither is any c: commands like c:forEach.
I know im probably missing something obvious but after 5 hours of searching I just got no answers. I presume its something to do with my VSCode settings or extensions or something else. Know some more details are probably needed, please ask anything.
Would love any suggestions on whats happening/what I am missing.
Example of code that otherwise works except for taglib and <c:forEach .
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<title>
Shopping List
</title>
<body>
<h1>Shopping List</h1>
<table>
<thead>
<tr><th>Product</th></tr>
</thead>
<tbody>
<c:forEach items=" ${ items }" var="shoppingListItem">
<tr><td>${ shoppingListItem.getTitle() }</td></tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
2
Answers
You install the Java Extension Pack for Visual Studio Code by Microsoft.
It includes several extensions (such as language support, a Java debugger, IntelliCode for Java) that make Java development in VS Code a snap.
Just click on the Extensions button (over on the left, looks like a Rubik’s cube being taken apart). Search for it on the Marketplace. It’s free. Download and install.
Good luck!
"Extension Pack for Java" does not include JSP support.
JSP extension is available at
https://marketplace.visualstudio.com/items?itemName=pthorsson.vscode-jsp
However, the JSP extension is not maintained. There are currently no active JSP extensions available for VSCode.