You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by LiuYan 刘研 <lo...@mail.china.com> on 2007/06/18 11:17:24 UTC

Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Is there a config for JSP compiler to ignore all white space characters which
out of <%...%> in JSP and/or tag directive lines?

Suppose the following code in JSP file:
--------------------------------------------------------------------------------
<%@ page contentType="text/html; charset=utf-8" language="java"
import="java.sql.*%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ include file="include_checkLogin.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
......
	<c:forEach var="project" items="${MY_PROJECTS}">
		<option value="<c:out value="${project.id}" default=""/>"<c:if
test="${project.id == param['projectID']}">
selected="selected"</c:if>><c:out value="${project.name}"
default=""/></option>
	</c:forEach>
......
......
--------------------------------------------------------------------------------



After it is compiled, it will be the following in .java file:
--------------------------------------------------------------------------------
  public void _jspService(HttpServletRequest request, HttpServletResponse
response)
        throws java.io.IOException, ServletException {
......
      out.write("\r\n"); *** redundant empty lines in HTML; <%@ %> lines in
JSP
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
......
  private boolean _jspx_meth_c_005fforEach_005f2(PageContext
_jspx_page_context)
          throws Throwable {
......
        do {
          out.write("\r\n");  *** redundant \r\n in HTML.;	<c:forEach > line
in JSP;  If there are hundreds or even more options, then (-_-!) ......
          out.write("\t\t<option value=\"");
......
          out.write("</option>\r\n");
          out.write("\t");  *** redundant \t in HTML;	</c:forEach> line in
JSP
......
......
--------------------------------------------------------------------------------


As you see, some redundant empty lines and leading spaces(tab char) will be
generated, 
although I can put all JSP and/or tag directives in one line to avoid these
redundant empty lines be generated, 
but it will make the JSP code hard to read.

So in a general thinking, is there a way to be satisfied with 
both developer whom want a well formatted JSP source and the end user whom
want a clean HTML result? :computer-user:

-- 
View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11172259
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Re[2]: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by Leon Rosenberg <ro...@googlemail.com>.
its not a filter, its a parameter to the jsp servlet, which is in the
web.xml of tomcat (located under conf in 5.5) either way.

regards
Leon





On 6/18/07, 吴熊敏 <xw...@ublearning.com> wrote:
> Thanks very much in advance!!!
>
> But i think it's not a good way to do this in web.xml.
>
>
> Is there any way to trim spaces when compile the jsp/servlet files but
> not use the filter?
>
> On Mon, 18 Jun 2007 11:56:01 +0200
> "Leon Rosenberg" <ro...@googlemail.com> wrote:
>
> > trimSpaces was once a setting in the declaration of the jsp servlet in
> > the web.xml
> >
> >    <servlet>
> >         <servlet-name>jsp</servlet-name>
> >         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
> >         <init-param>
> >             <param-name>trimSpaces</param-name>
> >             <param-value>true</param-value>
> >         </init-param>
> > ...
> >
> >
> > regards
> > Leon
> >
> > On 6/18/07, 吴熊敏 <xw...@ublearning.com> wrote:
> > > YES,IT'S a good idea,is there anyone who knows how to solve this issue?
> > >
> > > Thank you for the first!!
> > >
> > > On Mon, 18 Jun 2007 02:17:24 -0700 (PDT)
> > > LiuYan_刘研 <lo...@mail.china.com> wrote:
> > >
> > > >
> > > > Is there a config for JSP compiler to ignore all white space characters which
> > > > out of <%...%> in JSP and/or tag directive lines?
> > > >
> > > > Suppose the following code in JSP file:
> > > > --------------------------------------------------------------------------------
> > > > <%@ page contentType="text/html; charset=utf-8" language="java"
> > > > import="java.sql.*%>
> > > > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> > > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
> > > > prefix="logic"%>
> > > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
> > > > <%@ include file="include_checkLogin.jsp" %>
> > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > > > <html xmlns="http://www.w3.org/1999/xhtml">
> > > > ......
> > > >       <c:forEach var="project" items="${MY_PROJECTS}">
> > > >               <option value="<c:out value="${project.id}" default=""/>"<c:if
> > > > test="${project.id == param['projectID']}">
> > > > selected="selected"</c:if>><c:out value="${project.name}"
> > > > default=""/></option>
> > > >       </c:forEach>
> > > > ......
> > > > ......
> > > > --------------------------------------------------------------------------------
> > > >
> > > >
> > > >
> > > > After it is compiled, it will be the following in .java file:
> > > > --------------------------------------------------------------------------------
> > > >   public void _jspService(HttpServletRequest request, HttpServletResponse
> > > > response)
> > > >         throws java.io.IOException, ServletException {
> > > > ......
> > > >       out.write("\r\n"); *** redundant empty lines in HTML; <%@ %> lines in
> > > > JSP
> > > >       out.write("\r\n");
> > > >       out.write("\r\n");
> > > >       out.write("\r\n");
> > > >       out.write("\r\n");
> > > >       out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
> > > > Transitional//EN\"
> > > > \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
> > > > ......
> > > >   private boolean _jspx_meth_c_005fforEach_005f2(PageContext
> > > > _jspx_page_context)
> > > >           throws Throwable {
> > > > ......
> > > >         do {
> > > >           out.write("\r\n");  *** redundant \r\n in HTML.;    <c:forEach > line
> > > > in JSP;  If there are hundreds or even more options, then (-_-!) ......
> > > >           out.write("\t\t<option value=\"");
> > > > ......
> > > >           out.write("</option>\r\n");
> > > >           out.write("\t");  *** redundant \t in HTML; </c:forEach> line in
> > > > JSP
> > > > ......
> > > > ......
> > > > --------------------------------------------------------------------------------
> > > >
> > > >
> > > > As you see, some redundant empty lines and leading spaces(tab char) will be
> > > > generated,
> > > > although I can put all JSP and/or tag directives in one line to avoid these
> > > > redundant empty lines be generated,
> > > > but it will make the JSP code hard to read.
> > > >
> > > > So in a general thinking, is there a way to be satisfied with
> > > > both developer whom want a well formatted JSP source and the end user whom
> > > > want a clean HTML result? :computer-user:
> > > >
> > > > --
> > > > View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11172259
> > > > Sent from the Tomcat - User mailing list archive at Nabble.com.
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To start a new topic, e-mail: users@tomcat.apache.org
> > > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
> > > ----------------------------
> > > 吴熊敏 <xw...@ublearning.com>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To start a new topic, e-mail: users@tomcat.apache.org
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
> > >
>
> ----------------------------
> 吴熊敏 <xw...@ublearning.com>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re[2]: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by 吴熊敏 <xw...@ublearning.com>.
Thanks very much in advance!!!

But i think it's not a good way to do this in web.xml.


Is there any way to trim spaces when compile the jsp/servlet files but
not use the filter?

On Mon, 18 Jun 2007 11:56:01 +0200
"Leon Rosenberg" <ro...@googlemail.com> wrote:

> trimSpaces was once a setting in the declaration of the jsp servlet in
> the web.xml
> 
>    <servlet>
>         <servlet-name>jsp</servlet-name>
>         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
>         <init-param>
>             <param-name>trimSpaces</param-name>
>             <param-value>true</param-value>
>         </init-param>
> ...
> 
> 
> regards
> Leon
> 
> On 6/18/07, 吴熊敏 <xw...@ublearning.com> wrote:
> > YES,IT'S a good idea,is there anyone who knows how to solve this issue?
> >
> > Thank you for the first!!
> >
> > On Mon, 18 Jun 2007 02:17:24 -0700 (PDT)
> > LiuYan_刘研 <lo...@mail.china.com> wrote:
> >
> > >
> > > Is there a config for JSP compiler to ignore all white space characters which
> > > out of <%...%> in JSP and/or tag directive lines?
> > >
> > > Suppose the following code in JSP file:
> > > --------------------------------------------------------------------------------
> > > <%@ page contentType="text/html; charset=utf-8" language="java"
> > > import="java.sql.*%>
> > > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
> > > prefix="logic"%>
> > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
> > > <%@ include file="include_checkLogin.jsp" %>
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > > <html xmlns="http://www.w3.org/1999/xhtml">
> > > ......
> > >       <c:forEach var="project" items="${MY_PROJECTS}">
> > >               <option value="<c:out value="${project.id}" default=""/>"<c:if
> > > test="${project.id == param['projectID']}">
> > > selected="selected"</c:if>><c:out value="${project.name}"
> > > default=""/></option>
> > >       </c:forEach>
> > > ......
> > > ......
> > > --------------------------------------------------------------------------------
> > >
> > >
> > >
> > > After it is compiled, it will be the following in .java file:
> > > --------------------------------------------------------------------------------
> > >   public void _jspService(HttpServletRequest request, HttpServletResponse
> > > response)
> > >         throws java.io.IOException, ServletException {
> > > ......
> > >       out.write("\r\n"); *** redundant empty lines in HTML; <%@ %> lines in
> > > JSP
> > >       out.write("\r\n");
> > >       out.write("\r\n");
> > >       out.write("\r\n");
> > >       out.write("\r\n");
> > >       out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
> > > Transitional//EN\"
> > > \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
> > > ......
> > >   private boolean _jspx_meth_c_005fforEach_005f2(PageContext
> > > _jspx_page_context)
> > >           throws Throwable {
> > > ......
> > >         do {
> > >           out.write("\r\n");  *** redundant \r\n in HTML.;    <c:forEach > line
> > > in JSP;  If there are hundreds or even more options, then (-_-!) ......
> > >           out.write("\t\t<option value=\"");
> > > ......
> > >           out.write("</option>\r\n");
> > >           out.write("\t");  *** redundant \t in HTML; </c:forEach> line in
> > > JSP
> > > ......
> > > ......
> > > --------------------------------------------------------------------------------
> > >
> > >
> > > As you see, some redundant empty lines and leading spaces(tab char) will be
> > > generated,
> > > although I can put all JSP and/or tag directives in one line to avoid these
> > > redundant empty lines be generated,
> > > but it will make the JSP code hard to read.
> > >
> > > So in a general thinking, is there a way to be satisfied with
> > > both developer whom want a well formatted JSP source and the end user whom
> > > want a clean HTML result? :computer-user:
> > >
> > > --
> > > View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11172259
> > > Sent from the Tomcat - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To start a new topic, e-mail: users@tomcat.apache.org
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> > ----------------------------
> > 吴熊敏 <xw...@ublearning.com>
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >

----------------------------
吴熊敏 <xw...@ublearning.com>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re[2]: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by 吴熊敏 <xw...@ublearning.com>.
If you really need space sometimes,you can use &nbsp;


On Mon, 18 Jun 2007 09:47:39 -0700 (PDT)
LiuYan_刘研 <lo...@mail.china.com> wrote:

> 
> Thank you Leon, the 'trimSpaces' servlet parameter works fine except some
> little issues: 
> 1. The span it trimmed is a little wider, it even trimmed the continuous
> empty lines and the leading white spaces of the first line after directives..
> <%@...%>
> <%@...%>
> 
> 
> 
> <%@...%>
> will output nothing to client, but I want to keep the empty line 3,4,5 which
> are not in the same lines to directives.
> 
> 
> 2. the evaluated body in <c:forEach></forEach> is trimmed as the same indent
> as the tag directive if there are differnce between them. see the following
> example JSP code:
> --------------------------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> <%@ page
>   session="true"
>   contentType="text/html; charset=UTF-8"
>   import="java.util.*"
> %>
> 
> <%-- JSTL 1.1 tag library --%>
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
> <%-- JSTL 1.0 tag library --%>
> <%--@ taglib prefix="c" uri="http://java.sun.com/jstl/core" --%>
> 
> <%-- 中文 used for save this file as UTF-8 encoding --%>
> <html>
> <head>
> <style type="text/css">
> pre,code { border:1px solid}
> </style>
> </head>
> <body>
> 
> <%
> ArrayList<String> arrayTest =  new ArrayList<String>();
> pageContext.setAttribute ("test", arrayTest);
> for(int i=1; i<=5; i++)
> {
> 	arrayTest.add (String.valueOf(i));
> }
> %>
> 
> 
> 	<pre>
> 		Case 1: c:forEach has 0 indent, non-whitespace characters occurs BEFORE
> c:out
> <c:forEach var="t" items="${test}">
> 		Line <c:out value="${t}"/>
> </c:forEach>
> 	</pre>
> 	<pre>
> 		Case 2: c:forEach has 2 tabs indent, non-whitespace characters occurs
> BEFORE c:out
> 		<c:forEach var="t" items="${test}">
> 		Line <c:out value="${t}"/>
> 		</c:forEach>
> 	</pre>
> 	<pre>
> 		Case 3: c:forEach has 0 indent, non-whitespace characters occurs AFTER
> c:out
> <c:forEach var="t" items="${test}">
> 		<c:out value="${t}"/> Line
> </c:forEach>
> 	</pre>
> 	<pre>
> 		Case 4: c:forEach has 2 tabs indent, non-whitespace characters occurs
> AFTER c:out
> 		<c:forEach var="t" items="${test}">
> 		<c:out value="${t}"/> Line
> 		</c:forEach>
> 	</pre>
> 	<pre>
> 		Case 5: c:forEach has 2 tabs indent, there are no non-whitespace
> characters around c:out
> 		<c:forEach var="t" items="${test}">
> 		<c:out value="${t}"/>
> 		</c:forEach>
> 	</pre>
> 	<table border="1">
> 		<tr>
> 			<c:forEach var="t" items="${test}">
> 			<td>
> 				<c:out value="${t}"/>
> 			</td>
> 			</c:forEach>
> 		</tr>
> 	</table>
> 
> </body>
> </html>
> --------------------------------------------------------
> Unfortunately, non of these 5 cases meet my demand.
> 
> The behaviour of 'trimSpaces' in my mind will be:
> 1. Trim only whitespace characters if there are no non-whitespace characters
> in the directive line
> 2. An exception to 1: Do not trim whitespace characters which the directive
> will generate outputs (such as c:out of JSTL or bean:write, bean:message of
> struts ), maybe this is a trouble to JSP compiler, because it needs knows
> behaviour of tags: which tags are logical tags and which tags are html tags,
> but it is really good if 'trimSpaces' can achieve this.
> 3. Do not trim any other lines which does not contain directives.
> 
> Wish the JSP compiler can enhance 'trimSpaces' in details...
> (I'm thinking: Am I a boring man... -_-!)
> 
> But anyways, the 'trimSpaces' parameter is a good stuff for me now than
> having not it.
> 
> 
> 
> Leon Rosenberg-3 wrote:
> > 
> > trimSpaces was once a setting in the declaration of the jsp servlet in
> > the web.xml
> > 
> >    <servlet>
> >         <servlet-name>jsp</servlet-name>
> >        
> > <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
> >         <init-param>
> >             <param-name>trimSpaces</param-name>
> >             <param-value>true</param-value>
> >         </init-param>
> > ...
> > 
> > 
> > regards
> > Leon
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11179552
> Sent from the Tomcat - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

----------------------------
吴熊敏 <xw...@ublearning.com>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by LiuYan 刘研 <lo...@mail.china.com>.
Thank you Leon, the 'trimSpaces' servlet parameter works fine except some
little issues: 
1. The span it trimmed is a little wider, it even trimmed the continuous
empty lines and the leading white spaces of the first line after directives.
<%@...%>
<%@...%>



<%@...%>
will output nothing to client, but I want to keep the empty line 3,4,5 which
are not in the same lines to directives.


2. the evaluated body in <c:forEach></forEach> is trimmed as the same indent
as the tag directive if there are differnce between them. see the following
example JSP code:
--------------------------------------------------------








<%@ page
  session="true"
  contentType="text/html; charset=UTF-8"
  import="java.util.*"
%>

<%-- JSTL 1.1 tag library --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%-- JSTL 1.0 tag library --%>
<%--@ taglib prefix="c" uri="http://java.sun.com/jstl/core" --%>

<%-- 中文 used for save this file as UTF-8 encoding --%>
<html>
<head>
<style type="text/css">
pre,code { border:1px solid}
</style>
</head>
<body>

<%
ArrayList<String> arrayTest =  new ArrayList<String>();
pageContext.setAttribute ("test", arrayTest);
for(int i=1; i<=5; i++)
{
	arrayTest.add (String.valueOf(i));
}
%>


	<pre>
		Case 1: c:forEach has 0 indent, non-whitespace characters occurs BEFORE
c:out
<c:forEach var="t" items="${test}">
		Line <c:out value="${t}"/>
</c:forEach>
	</pre>
	<pre>
		Case 2: c:forEach has 2 tabs indent, non-whitespace characters occurs
BEFORE c:out
		<c:forEach var="t" items="${test}">
		Line <c:out value="${t}"/>
		</c:forEach>
	</pre>
	<pre>
		Case 3: c:forEach has 0 indent, non-whitespace characters occurs AFTER
c:out
<c:forEach var="t" items="${test}">
		<c:out value="${t}"/> Line
</c:forEach>
	</pre>
	<pre>
		Case 4: c:forEach has 2 tabs indent, non-whitespace characters occurs
AFTER c:out
		<c:forEach var="t" items="${test}">
		<c:out value="${t}"/> Line
		</c:forEach>
	</pre>
	<pre>
		Case 5: c:forEach has 2 tabs indent, there are no non-whitespace
characters around c:out
		<c:forEach var="t" items="${test}">
		<c:out value="${t}"/>
		</c:forEach>
	</pre>
	<table border="1">
		<tr>
			<c:forEach var="t" items="${test}">
			<td>
				<c:out value="${t}"/>
			</td>
			</c:forEach>
		</tr>
	</table>

</body>
</html>
--------------------------------------------------------
Unfortunately, non of these 5 cases meet my demand.

The behaviour of 'trimSpaces' in my mind will be:
1. Trim only whitespace characters if there are no non-whitespace characters
in the directive line
2. An exception to 1: Do not trim whitespace characters which the directive
will generate outputs (such as c:out of JSTL or bean:write, bean:message of
struts ), maybe this is a trouble to JSP compiler, because it needs knows
behaviour of tags: which tags are logical tags and which tags are html tags,
but it is really good if 'trimSpaces' can achieve this.
3. Do not trim any other lines which does not contain directives.

Wish the JSP compiler can enhance 'trimSpaces' in details...
(I'm thinking: Am I a boring man... -_-!)

But anyways, the 'trimSpaces' parameter is a good stuff for me now than
having not it.



Leon Rosenberg-3 wrote:
> 
> trimSpaces was once a setting in the declaration of the jsp servlet in
> the web.xml
> 
>    <servlet>
>         <servlet-name>jsp</servlet-name>
>        
> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
>         <init-param>
>             <param-name>trimSpaces</param-name>
>             <param-value>true</param-value>
>         </init-param>
> ...
> 
> 
> regards
> Leon
> 

-- 
View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11179552
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by Leon Rosenberg <ro...@googlemail.com>.
trimSpaces was once a setting in the declaration of the jsp servlet in
the web.xml

   <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>trimSpaces</param-name>
            <param-value>true</param-value>
        </init-param>
...


regards
Leon

On 6/18/07, 吴熊敏 <xw...@ublearning.com> wrote:
> YES,IT'S a good idea,is there anyone who knows how to solve this issue?
>
> Thank you for the first!!
>
> On Mon, 18 Jun 2007 02:17:24 -0700 (PDT)
> LiuYan_刘研 <lo...@mail.china.com> wrote:
>
> >
> > Is there a config for JSP compiler to ignore all white space characters which
> > out of <%...%> in JSP and/or tag directive lines?
> >
> > Suppose the following code in JSP file:
> > --------------------------------------------------------------------------------
> > <%@ page contentType="text/html; charset=utf-8" language="java"
> > import="java.sql.*%>
> > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
> > prefix="logic"%>
> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
> > <%@ include file="include_checkLogin.jsp" %>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml">
> > ......
> >       <c:forEach var="project" items="${MY_PROJECTS}">
> >               <option value="<c:out value="${project.id}" default=""/>"<c:if
> > test="${project.id == param['projectID']}">
> > selected="selected"</c:if>><c:out value="${project.name}"
> > default=""/></option>
> >       </c:forEach>
> > ......
> > ......
> > --------------------------------------------------------------------------------
> >
> >
> >
> > After it is compiled, it will be the following in .java file:
> > --------------------------------------------------------------------------------
> >   public void _jspService(HttpServletRequest request, HttpServletResponse
> > response)
> >         throws java.io.IOException, ServletException {
> > ......
> >       out.write("\r\n"); *** redundant empty lines in HTML; <%@ %> lines in
> > JSP
> >       out.write("\r\n");
> >       out.write("\r\n");
> >       out.write("\r\n");
> >       out.write("\r\n");
> >       out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
> > Transitional//EN\"
> > \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
> > ......
> >   private boolean _jspx_meth_c_005fforEach_005f2(PageContext
> > _jspx_page_context)
> >           throws Throwable {
> > ......
> >         do {
> >           out.write("\r\n");  *** redundant \r\n in HTML.;    <c:forEach > line
> > in JSP;  If there are hundreds or even more options, then (-_-!) ......
> >           out.write("\t\t<option value=\"");
> > ......
> >           out.write("</option>\r\n");
> >           out.write("\t");  *** redundant \t in HTML; </c:forEach> line in
> > JSP
> > ......
> > ......
> > --------------------------------------------------------------------------------
> >
> >
> > As you see, some redundant empty lines and leading spaces(tab char) will be
> > generated,
> > although I can put all JSP and/or tag directives in one line to avoid these
> > redundant empty lines be generated,
> > but it will make the JSP code hard to read.
> >
> > So in a general thinking, is there a way to be satisfied with
> > both developer whom want a well formatted JSP source and the end user whom
> > want a clean HTML result? :computer-user:
> >
> > --
> > View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11172259
> > Sent from the Tomcat - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
>
> ----------------------------
> 吴熊敏 <xw...@ublearning.com>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?

Posted by 吴熊敏 <xw...@ublearning.com>.
YES,IT'S a good idea,is there anyone who knows how to solve this issue?

Thank you for the first!!

On Mon, 18 Jun 2007 02:17:24 -0700 (PDT)
LiuYan_刘研 <lo...@mail.china.com> wrote:

> 
> Is there a config for JSP compiler to ignore all white space characters which
> out of <%...%> in JSP and/or tag directive lines?
> 
> Suppose the following code in JSP file:
> --------------------------------------------------------------------------------
> <%@ page contentType="text/html; charset=utf-8" language="java"
> import="java.sql.*%>
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
> <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
> prefix="logic"%>
> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
> <%@ include file="include_checkLogin.jsp" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> ......
> 	<c:forEach var="project" items="${MY_PROJECTS}">
> 		<option value="<c:out value="${project.id}" default=""/>"<c:if
> test="${project.id == param['projectID']}">
> selected="selected"</c:if>><c:out value="${project.name}"
> default=""/></option>
> 	</c:forEach>
> ......
> ......
> --------------------------------------------------------------------------------
> 
> 
> 
> After it is compiled, it will be the following in .java file:
> --------------------------------------------------------------------------------
>   public void _jspService(HttpServletRequest request, HttpServletResponse
> response)
>         throws java.io.IOException, ServletException {
> ......
>       out.write("\r\n"); *** redundant empty lines in HTML; <%@ %> lines in
> JSP
>       out.write("\r\n");
>       out.write("\r\n");
>       out.write("\r\n");
>       out.write("\r\n");
>       out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
> Transitional//EN\"
> \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
> ......
>   private boolean _jspx_meth_c_005fforEach_005f2(PageContext
> _jspx_page_context)
>           throws Throwable {
> ......
>         do {
>           out.write("\r\n");  *** redundant \r\n in HTML.;	<c:forEach > line
> in JSP;  If there are hundreds or even more options, then (-_-!) ......
>           out.write("\t\t<option value=\"");
> ......
>           out.write("</option>\r\n");
>           out.write("\t");  *** redundant \t in HTML;	</c:forEach> line in
> JSP
> ......
> ......
> --------------------------------------------------------------------------------
> 
> 
> As you see, some redundant empty lines and leading spaces(tab char) will be
> generated, 
> although I can put all JSP and/or tag directives in one line to avoid these
> redundant empty lines be generated, 
> but it will make the JSP code hard to read.
> 
> So in a general thinking, is there a way to be satisfied with 
> both developer whom want a well formatted JSP source and the end user whom
> want a clean HTML result? :computer-user:
> 
> -- 
> View this message in context: http://www.nabble.com/Is-there-a-config-for-JSP-compiler-to-ignore--%5Cs--chars-in-JSP-directive-line--tf3939116.html#a11172259
> Sent from the Tomcat - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

----------------------------
吴熊敏 <xw...@ublearning.com>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org