Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 32193 invoked from network); 8 Mar 2002 23:28:55 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 8 Mar 2002 23:28:55 -0000 Received: (qmail 23185 invoked by uid 97); 8 Mar 2002 23:28:38 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 23169 invoked by uid 97); 8 Mar 2002 23:28:38 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 23158 invoked from network); 8 Mar 2002 23:28:37 -0000 Message-Id: <5.1.0.14.0.20020308152316.009fba40@mail.harbornet.com> X-Sender: caraunltd@mail.harbornet.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 08 Mar 2002 15:26:40 -0800 To: "Tomcat Users List" From: Micael Padraig Og mac Grene Subject: RE: Processing BodyContent in doAfterTag() has no effect In-Reply-To: <20020308225741.627.qmail@fancyfeast.chek.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Here is a suggested replace method (sorry for saying function). Cross-language pollution: private String replace(String content, String before, String after) { int cursor = content.indexOf(before); while (cursor > -1) { content = content.substring(0, cursor) + after + content.substring(cursor + before.length()); cursor = content.indexOf(before, cursor + after.length()); } return content; } Hope this helps. I am pretty sure your problem is a misunderstanding of the StringTokenizer class. The token used to tokenize is removed from the tokens. Your code seems to assume otherwise. This replace will be a lot faster, anyway. Micael At 10:57 PM 3/8/02 +0000, you wrote: >Thanks for your help. But I don't think that is >causing the problem: > (a) for one thing, the other text written to > body content show up in the output. Only the > stuff inserted into the enclosing writer in > doAfterBody() is mysteriously missing. > > (b) I am writing to the enclosing JspWriter - > not to the body content. > >Consider the following: > > > > I am a Laker Fan. I am Kobe. > > > >What appears on output is: > I AM A LAKER FAN I AM KOBE > >The periods are missing. What (I think) my doAfterBody() >is doing is to replace "." tokens with ".
" tokens. >Can you tell me where the
tokens that I inserted >vanished? > > /K > >On Fri, 8 Mar 2002 01:52:33 -0500 Ryan Daigle wrote: > >I believe you have to flush the writer out to the body content of the tag at > >the end tag event: > > > >doEndTag() throws JspException { > > bodyContent.writeOut(YourWriter); > >} > > > >That work? > > > >-----Original Message----- > >From: K Br [mailto:kobe@ny.com] > >Sent: Thursday, March 07, 2002 6:29 PM > >To: tomcat-user@jakarta.apache.org > >Subject: Processing BodyContent in doAfterTag() has no effect > > > > > >This is no JSP forum and I understand that. > >I would appreciate any pointers on this. > > > >Using Tomcat4.0.2 I have written a custom tag with body. > >The intention is to process the body and > >replace any periods with line breaks (in HTML) > >before writing the BodyContent to the > >enclosing JspWriter. > > > >It seems that replacing "." with ".
" does not > >take any effect. The output HTML does not contain > >the
tags (when viewed from the browser). > > > >From the doAfterBody() I call the filter > >to replace the periods with
as follows. > > > >Pl let me know if my understanding of the > >TAG lifecycle is wrong: > > > >public int doAfterBody() throws JspException { > >try { > >String txt = getBodyContent().getString(); > >replaceDots(txt.toLowerCase() > >getPreviousOut() > >); > >} > >catch (java.io.IOException ioxc) { > >throw new JspException(ioxc.toString()); > >} > > > >return SKIP_BODY; > >} > > > >private void replaceDots(final String x, JspWriter w) > >throws java.io.IOException > >{ > >if (x == null) return ; > >StringTokenizer st = new StringTokenizer(x, "."); > >while (st.hasMoreTokens()) { > >String f = (String)st.nextToken(); > >w.println( f.equals(".") ? ".
":f); > >} > >} > > > > > > > >-- > >To unsubscribe: > >For additional commands: > >Troubles with the list: > > > >-- > >To unsubscribe: > >For additional commands: > >Troubles with the list: > > > > > > > >-- >To unsubscribe: >For additional commands: >Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: