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"
    pageEncoding="UTF-8"
    trimDirectiveWhitespaces="true"%>
<!DOCTYPE html>
<html>  
    <body>
Server info: <%= application.getServerInfo() %><br>  
Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>  
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
    </body>
</html>

img/0/53/screen1.JPG