JSP Document - JSP Version Error

This section provides tutorial example on how to verify what JSP versions are supported by Tomcat server using an invalid version number in a JSP Document.

If you want to know what JSP versions are supported by Apache Tomcat server, you can specify an invalid version number in the root element of a JSP Document. Tomcat will return an error and list all JSP version it supports.

Here is my version test example in JSP Document XML format:

<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="?">
<!-- jsp_version_error.jspx
 - Copyright (c) 2006 HerongYang.com. All Rights Reserved.
-->
<jsp:directive.page contentType="text/html"/>
<html><body>
<jsp:scriptlet>out.println("JSP Version Error");</jsp:scriptlet>
</body></html>
</jsp:root>

Save the above document on the Tomcat server at: \local\tomcat\webapps\ROOT\jsp_version_error.jspx.

Then open this JSP Document with a Web browser with this URL: http://localhost:8080/jsp_version_error.jspx. The follow error shows up in the browser:

HTTP Status 500 – Internal Server Error
Type Exception Report

Message /jsp_version_error.jspx (line: [2], column: [64])
 Invalid version number: [?], must be "1.2", "2.0", "2.1", "2.2" or "2.3"

Description The server encountered an unexpected condition that prevented
it from fulfilling the request.

Exception
org.apache.jasper.JasperException:
 /jsp_version_error.jspx (line: [2], column: [64])
 Invalid version number: [?], must be "1.2", "2.0", "2.1", "2.2" or "2.3"
 org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
 org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)
 org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115)
 org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:531)
 org.apache.jasper.compiler.Node$JspRoot.accept(Node.java:554)
 org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)
 org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2441)
 org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2447)
 org.apache.jasper.compiler.Node$Root.accept(Node.java:470)
 org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)
 org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1856)
 org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:224)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:385)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:383)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Apache Tomcat/9.0.12

Now I know Tomcat 9.0.12 supports JSP "1.2", "2.0", "2.1", "2.2" or "2.3".

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

Syntax of JSP Pages and JSP Documents

 Syntactic Elements of a JSP Page

 JSP Document - JSP Page in XML Format

JSP Document - JSP Version Error

 Writing Scriptlet Element in XML Format

 Writing Directive Element in XML Format

 Writing Action Element in XML Format

 "include" Directive and Action Elements

 Execution Result of CurrentTime.jspx

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Using Tomcat on CentOS Systems

 Using Tomcat on macOS Systems

 Connecting to SQL Server from Servlet

 Developing Web Applications with Servlet

 Archived Tutorials

 References

 Full Version in PDF/EPUB