• hessian
  • quercus/php
  • resin 3.0
  • resin 3.1
  • resin 4.0

  • changes
  • configuration
  • examples
  • installing
  • overview
  • starting

  • guide: admin
  • admin
  • amber
  • bam
  • caching
  • clustering
  • comet
  • database
  • deployment
  • ejb 3.0
  • embedding
  • filters
  • ioc
  • jsf
  • jsp
  • logging
  • messaging
  • quercus
  • remoting
  • security
  • resources
  • servlets
  • third-party
  • troubleshooting
  • virtual host
  • watchdog
  • webapp
  • HOME
  • ABOUT
  • ARTICLES
  • WORKSPACE
  • NEWS
  • PROJECTS
  • PRODUCTS
  • STORE
resin
  • hessian
  • quercus/php
  • resin 3.0
  • resin 3.1
  • resin 4.0

  • changes
  • configuration
  • examples
  • installing
  • overview
  • starting

  • guide: admin
  • admin
  • amber
  • bam
  • caching
  • clustering
  • comet
  • database
  • deployment
  • ejb 3.0
  • embedding
  • filters
  • ioc
  • jsf
  • jsp
  • logging
  • messaging
  • quercus
  • remoting
  • security
  • resources
  • servlets
  • third-party
  • troubleshooting
  • virtual host
  • watchdog
  • webapp
  • HOME
  • ABOUT
  • ARTICLES
  • WORKSPACE
  • NEWS
  • PROJECTS
  • PRODUCTS
  • STORE

I'm getting a lot of whitespace in my JSP that I don't intend to be there. Why is it appearing and how can I get rid of it?

The extra whitespace is coming from newlines, often at the end of declaration lines at the beginning of the JSP. For example, the following jsp:

<%@ page import='java.util.*' %> <%@ page import='java.io.*' %> Hello world

Has newlines in these locations:

<%@ page import='java.util.*' %>NL <%@ page import='java.io.*' %>NL Hello worldNL

The result contains the newlines, which may be surprising:

Hello world

One solution is to let the JSP tag extend across the newline:

<%@ page import='java.util.*' %><%@ page import='java.io.*' %>Hello world

Another solution is to use JSP comments to remove the newlines:

<%@ page import='java.util.*' %><%-- --%><%@ page import='java.io.*' %><%-- --%>Hello world

Another solution is to use the XML syntax of JSP. Parsing of XML causes removal of extra whitespace.

<jsp:root> <jsp:directive.page import="java.util.*"/> <jsp:directive.page import="java.io.*"/> <jsp:text>Hello world</jsp:text> </jsp:root>

Resin also supports the use of the '\' character to eat whitespace (this is a Resin specific feature):

<%@ page import='java.util.*' %>\ <%@ page import='java.io.*' %>\ Hello world
  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • SALES |
  • WIKI
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.
  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • SALES |
  • WIKI
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.