Remove Spacing Between Jsp Variables
have a problem with the spacing between this jsp calls <%=Constants.getTextInput('', Texts.RNG_IDENT_MSG, '', '', 19)%><%=Constant
Solution 1:
You can use the directive trimDirectiveWhitespaces
<%@ page trimDirectiveWhitespaces="true"%>
This should remove white spaces between actions, scriptlets and directives.
Here an example of what i get on Glassfish 4.0:
with <%@ page trimDirectiveWhitespaces="true"%> in the jsp
<%@ page trimDirectiveWhitespaces="true"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><table><tr>
<%="1111111111"%>
<%="2222222222"%>
<c:outvalue="c:out"></c:out><c:outvalue="LOOP"></c:out><c:forEachbegin="1"end="5"step="1"var="y">
${'qqqqq'} ${'RRR'}
<c:outvalue="c:out"></c:out>
<% out.println("InTheLoop"); %>
</c:forEach></tr></table></body></html>
Source code received in browser:
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><table><tr>
11111111112222222222c:outLOOPqqqqqRRRc:outInTheLoop
qqqqqRRRc:outInTheLoop
qqqqqRRRc:outInTheLoop
qqqqqRRRc:outInTheLoop
qqqqqRRRc:outInTheLoop
</tr></table></body></html>
The same JSP code as above but with <%@ page trimDirectiveWhitespaces="false"%> Or without trimDirectiveWhitespaces at all produce the folowing code received in browser:
<!DOCTYPE htmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><table><tr>
1111111111
2222222222
c:out
LOOP
qqqqq RRR
c:out
InTheLoop
qqqqq RRR
c:out
InTheLoop
qqqqq RRR
c:out
InTheLoop
qqqqq RRR
c:out
InTheLoop
qqqqq RRR
c:out
InTheLoop
</tr></table></body></html>
So with trimDirectiveWhitespace="true":
- you can remove whitespaces between actions, scriptlets, expressions, directives.
- But you can NOT remove whitespaces between other html tags
Post a Comment for "Remove Spacing Between Jsp Variables"