Search code examples
javajspjsp-tagsscriptlet

JSP When to use empty scriptlet tags


Often when developing, I come across the following: -

<%%>

Totally empty scriptlet tags.

In the past, removing this "mere nuisance" polluting the codebase has caused my JSP's not to work.

  • What is the purpose of these empty scriptlet tags?

Solution

  • Ultimately JSP pages are compiled to .java files which compile to .class files.

    I seem to remember that literal strings in a .java file have a maximum size limit. I'm guessing that <%%> was added to the middle of a very long piece of static html in the JSP to force two or more string literals in the resultant .java file.

    It might be related to this question which suggests:

    The value of the code_length item must be less than 65536.