开发者

J2EE - How to remove empty space,blank lines from server response

Is there a way to remove blank lines from server response? I have tried out:

<init-param>
          <param-name>trimSpaces</param-name>
          <param-value>true</param-value>
</init-param>

and

<%@ page trimDirectiveWhitespaces="true"%>

which didn'开发者_运维技巧t solve the issue properly since in init param method it removed even space between words, 2nd method didn't work either since it needs java servlet version to be 2.5.

Your advice will be very helpful ..


you should create a filter-servlet that remove blank lines and chained the response to your servlet.


when the server convert the JSP page to servlet it add implicitly blank lines (\n). add out.clear() befor writing data to clear out object.


Add the following directives to your page and the lines should disappear:

<%@ page contentType="text/xml" %>
<%@page pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>


I think, you should use an IDE like eclipse. Where you can just select the whole code and format it and follow all java syntax guidelines by just right clicking and seletcing a few options. Please use good IDE's all of them will help you follow good guidelines and make your work simpler and easier to read and understand

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜