hi!!
   I'm kind of new to tag libs, I wanted to create a
Body tag that could zip the contents in the tags to
browser. the code is ....

public class Content
                extends
javax.servlet.jsp.tagext.BodyTagSupport {
 public int doAfterBody()
                             throws
javax.servlet.jsp.JspTagException{

  BodyContent bodyContent = getBodyContent();
  String body = bodyContent.getString();
  bodyContent.clearBody();
  try{
   javax.servlet.http.HttpServletResponse res =

(javax.servlet.http.HttpServletResponse)pageContext.getResponse();

   res.setHeader("Content-Encoding", "gzip");
   //JspWriter myOut = pageContext.getOut();
  //Problem at run time  "ClassCastException "
   JspWriter myOut = (JspWriter)
getPreviousOut().getClass().newInstance();
   bodyContent = (BodyContent) myOut;
   java.io.OutputStream browser =
res.getOutputStream();
   java.io.PrintWriter writer = new
java.io.PrintWriter(new
java.util.zip.GZIPOutputStream(browser),false);
   bodyContent.writeOut(writer);
   bodyContent.print(body);
   writer.flush();
   bodyContent.flush();
   writer.close();
  }catch(Exception e){
   throw new
javax.servlet.jsp.JspTagException(e.getMessage());
  }
  return javax.servlet.jsp.tagext.Tag.SKIP_BODY;
 }
}


Problems...!!
1) In line 15, I'm trying to access JspWriter like
     JspWriter myOut = (JspWriter)
getPreviousOut().getClass().newInstance();
   this throws a ClassCast Exception, cause at run
time
     getPreviousOut() returns me a "JspWriterImpl"
object. When I try to type cast to    BodyContent
(subclass of JspWriter) it gives me a Class Cast
exception.But if I  tried  with pageContext.getOut()
it works fine(No Class Cast Exception , but no output
in browser).
  - is there any other way that I can get the
JspWriter.

2) When I tried to use pageContext.getOut(),
        There is no output in the browser. Is it
anything wrong in the "response" object. Or is it
possible to pass a PrintWriter object  to
BodyContent.writeOut();

Please let me know  is there any solution for this
problem. I'm running on wheels for last couple of
days.

my work enviroment is weblogic 5.1 on NT workstation
4.0
Thanks,
Kumar


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to