|
 |
pro_jsp thread: Compression of JSP pages
Message #1 by "Lior Shliechkorn" <lior@f...> on Wed, 5 Mar 2003 14:55:51
|
|
Hi,
I'm stuck on this matter right now with the whole compression of the
response object. Basically what I want to acheive is a better performance
from my tags that are generating a report.
I have a JSP page with the include page directives and some variable
declarations in the JSP page already, as well as a tag. Now the tag
basically generates a table with fields read in from a file (and I will
later create more tags that will read from a database). Now my question
is this, do I need to have everything written to the client with a
printWriter object in order to compress the response object? I have too
many pages that will need this implementation and I can't afford to go
back and put out.println() in all the pages.
This is some code from the 1 page I need to compress:
<%@ page isThreadSafe="true" %>
<%@ page session="true" %>
<%@ page buffer="32k" %>
<%@ page language = "java" errorPage = "errorpage.jsp" %>
<%@ page import = "java.util.Date.*, java.sql.*" %>
<%@ page import = "java.math.*, java.lang.Integer.*, java.lang.Double.*" %
>
<%@ page import = "java.lang.Float.*, java.lang.Number.*,
java.lang.String.*" %>
<%@ page contentType="text/html;charset=WINDOWS-1252" %><%
response.setHeader("pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
ServerBean serverBean = (ServerBean) session.getAttribute("serverbean");
boolean verbose = false;
String verb = request.getParameter("VERBOSE");
if (verb != null) {
verbose = true;
}
%><jsp:include page="globalHeader.jsp"><jsp:param name="pageVar"
value="10"/></jsp:include><%
Connection conn = null;
String asql = null;
String adate = null;
String aAcct = null;
Statement dstmt = null;
ResultSet drs = null;
try {
conn = (Connection) request.getAttribute("Connection");
dstmt1 = conn.createStatement();
drs1 = dstmt1.executeQuery(asql);
showTop = false; %>
<TABLE CELLSPACING="0" CELLPADDING="3" border="0">
<TR>
<TD><img src="<%=serverBean.getSERVERROOT()%
>/images/broker_daily_activity_report_hdr.gif" border="0"><br><br></TD>
</TR>
</TABLE>
<% while(drs1.next()) {
// In this IF statement we check if we have more than one account
// and separate the accounts with a horizontal line
if (rcdnumAccount >= 1) {%>
<TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0" border="0">
<TR align="right">
<TD align="right"><a href="#top"><img src="<%=serverBean.getSERVERROOT()%
>/images/back_top.gif" border="0"></a></TD>
</TR>
<TR>
<TD bgcolor="#666666" align="left"><img src="<%=serverBean.getSERVERROOT
()%>/images/trans.gif" border="0" height="2" width="100%"></TD>
</TR>
</TABLE>
Etc. etc. So you see that I have a lot of scriptlets inside the page, and
then I will put some of the code in a tag that will access a PrintWriter
object. But will I be able to make the page work with the following form:
<HTML>
...
<TABLE>
<TR>
<TD>Head1</TD>
<TD>Head2</TD>
<TD>Head3</TD>
<TD>Head4</TD>
<TR>
<tagName:doTheRest /> // to just dislpay fields
</TABLE>
And it will compress the out instance in the tag and still work? I'm just
not sure of how to go about implementing the compression filter. Since I
have some pages right now that I tried to make it work with, but the
pages are returned with no HTML, just a white screen.
Any help is great appreciated.
Thank you very much
|
|
 |