GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [jsp] Fix #5092: Allow XML declaration and doctype after other content by InnoxCodes · Pull Request #7252 · pmd/pmd

Conversation

@InnoxCodes

@InnoxCodes InnoxCodes commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Describe the PR

Prolog() in Jsp.jjt only allowed comments before the doctype, so a page starting with a directive like <%@ page contentType="text/html" %> failed with Encountered "<!DOCTYPE". It now also accepts directives, scriptlets and declarations there.

New test testDoctypeAfterJspDirectives in JspDocStyleTest fails on main and passes now. I ran all the pmd-jsp tests (150) and checkstyle for the module, not the whole ./mvnw clean verify. The issue has no file attached, so this matches the message but I can't be sure it's the reporter's exact case.

Related issues

  • Fix [jsp] Parse error when <!DOCTYPE> or <?xml?> follows other content #5092

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
InnoxCodes and others added 2 commits October 28, 2026 02:55
@InnoxCodes
[jsp] Fix pmd#5092: allow JSP directives and scriptlets before the do…
faa91ef
…ctype

The prolog of a JSP only accepted comments in front of the doctype
declaration, so the very common

    <%@ page contentType="text/html" %>
    <!DOCTYPE html>

failed with `Encountered "<!DOCTYPE"`. JSP directives, scriptlets,
declarations and comments are now accepted before the doctype.
@adangel
Merge branch 'main' into fix/jsp-doctype-after-directive
304bd6c
@pmd-actions-helper

pmd-actions-helper Bot commented Nov 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-11-20 13:08:44+00:00 for 1c9fb74)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adangel and others added 2 commits November 20, 2026 13:39
@adangel @claude
[jsp] Allow xml declaration and doctype anywhere in content
2bce806
Instead of extending the prolog with a list of JSP constructs, which
can never be complete, accept Declaration and DoctypeDeclaration as
regular content elements. According to the Jakarta Pages grammar there
is no prolog; both are just template text that may appear anywhere.

The prolog is unchanged, so ASTs of files that parsed before stay the
same. Directives before the doctype stay under Content, so JspEncoding
still finds the page directive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adangel @claude
[jsp] Use parameterized tests for doctype/xml declaration cases
5af7818
Co-Authored-By: Claude Opus 5.5 <[email protected]>
adangel
adangel reviewed Nov 20, 2026
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I'll use a slightly different approach: The JSP actually doesn't have a Prolog, so the grammar is not really correct here. And there could be more content appearing before the doctype. The official grammar is specificied here: https://jakarta.ee/specifications/pages/4.0/jakarta-server-pages-spec-4.0.html#ebnf-grammar-for-jsp-syntax

I'll update the PR myself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-jsp/src/main/javacc/Jsp.jjt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/JspDocStyleTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel changed the title [jsp] Fix #5092: allow JSP directives and scriptlets before the doctype [jsp] Fix #5092: Allow XML declaration and doctype after other content Nov 20, 2026
adangel
adangel reviewed Nov 20, 2026
View reviewed changes
Comment thread pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/ast/JspDocStyleTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@adangel @claude
[jsp] Use assertInstanceOf in doctype/xml declaration tests
1c9fb74
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adangel adangel added this to the 7.30.0 milestone Nov 20, 2026
adangel
adangel approved these changes Nov 20, 2026
View reviewed changes
@adangel
adangel merged commit cb78441 into pmd:main Nov 20, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel self-assigned this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adangel adangel

Labels

None yet

Projects

None yet

Milestone

7.30.0

Development

Successfully merging this pull request may close these issues.

[jsp] Parse error when <!DOCTYPE> or <?xml?> follows other content

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@InnoxCodes @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.