Article updated on

How to remove the blank line in JSP left by the directive

The blank line after JSP directive issue has been tackled from JSP 2.1 version and above. To sort this thing out just set the property trimDirectiveWhitespaces="true" which is set to false by default.

Use the code below to check your JSP version.

<%@ page language="java"
    contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
Server info: <%= application.getServerInfo() %><br>  
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>  
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>