tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 吴熊敏 <...@ublearning.com>
Subject Re: Is there a config for JSP compiler to ignore [\s] chars in JSP directive line?
Date Mon, 18 Jun 2007 09:47:22 GMT
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_刘研 <lovetide@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

----------------------------
吴熊敏 <xwu@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


Mime
View raw message