Development is frozen. The published package, documentation, examples, and changelog remain available.
Permalink to InstallationInstallation
Permalink to Quick TakeQuick Take
Permalink to ExamplesExamples
- Detect a JSP page directive
- Detect a JSP action tag
- Detect an expression that refers to a JSP property
- Reject HTML without JSP syntax
- Detect a JSP Standard Tag Library tag
- Match a JSP namespace declaration independently of the element prefix
API — isJSP()
The main function isJSP() is imported like this:
Returns a fresh global RegExp for JSP syntax hints. Use it with RegExp.prototype.exec() or String.prototype.match(). Classic scriptlets, expressions, declarations, directives, and comments match through their <% opening marker. A standalone %> is excluded, so a percentage comparison such as 100%>90% does not count as JSP evidence.
An opening <% alone is accepted as an incomplete editor fragment. This helper locates markers; it does not validate JSP or distinguish shared delimiters from EJS or ERB. Create a fresh regex for independent .test() calls, or reset lastIndex to zero.
The regex also finds quoted namespace declarations using the literal URI http://java.sun.com/JSP/Page, with a default namespace or any prefix, including Unicode prefixes. Both quote styles and XML whitespace around = are supported:
const input = '<root xmlns:j="http://java.sun.com/JSP/Page"><j:text>Hello</j:text></root>';
input.match(isJSP()); // ['xmlns:j="http://java.sun.com/JSP/Page"']
This added match is a declaration marker, so unused declarations and declarations written in comments or quoted prose can match too. The factory keeps its case-insensitive flag; it does not resolve namespace scope, compare XML names case-sensitively, or decode XML references in URI values. Use detect-templating-language when you need an actual element bound to the exact standard namespace. The URI remains the historical spelling in Jakarta Pages 4.0.
Bare jsp:, c:, and cms: opening tags and ${jsp...} property expressions remain permissive hints. An explicit namespace binding to a different URI does not suppress these textual regex matches; the classifier checks that distinction. Closing-only tags are not markers, and generic ${...} expressions or other tag-library namespace URIs are not added.
In the classifier, this also applies to explicit JSTL bindings: a bare <c:if/> remains a hint, while a c prefix bound only to a JSTL URI needs stronger JSP evidence, such as a classic taglib directive. Broader tag-library recognition remains outside this change.
API — version
You can import version: