tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Trollinger" <jaka...@trollingers.com>
Subject RE: Bug? in Tomcat 4.1.18 with TagLib
Date Thu, 06 Feb 2003 13:39:44 GMT
This is because of tag pooling.

Please see http://issues.apache.org/bugzilla/show_bug.cgi?id=13392 or
http://issues.apache.org/bugzilla/show_bug.cgi?id=16001 or
http://issues.apache.org/bugzilla/show_bug.cgi?id=10220

And there are lots more.

John

> -----Original Message-----
> From: Etienne [mailto:etienno@sympatico.ca] 
> Sent: Thursday, February 06, 2003 8:30 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Bug? in Tomcat 4.1.18 with TagLib
> 
> 
> Hi, 
>  
> I am new to this list, and I add problem retrieving archive, 
> so sorry if that question was already answered.
>  
> My web application was running on tomcat 3,2 and 4.0.3 it was 
> running well. Now that I have switch to Tomcat 4.1.18 I have 
> a strange problem with one of my custom tag. It seems that 
> the local variables in the
> doStartTag() method are not cleared after the tag, something 
> is not calling the clearProperties() method at the end of 
> each tag. But if I put clearProperties() inside the 
> doStartTag(), it is working better. But I cannot still get a 
> random number for each image. The main idea is that every tag 
> on the page is using the same value for some variable. It 
> shouldn't happen. Any idea?
>  
> By the way, I think I can fix it by clearing each value in 
> the doStartTag(), but I still don't understand why is was 
> working on Tomcat 3.2, 4.0.3 and not and 4.1.8. The specs 
> says that the variables should be clean with the 
> clearProperties() after the end of the tag. Is there a 
> problem of configuration on my side?
>  
> Here's the code, I use the Manning "Jsp Tag Library" classes 
> as a base.
>  
> package my.taglib.html;
>  
> import my.taglib.util.LocalStrings;
> import my.taglib.util.ExTagSupport;
> import java.util.Properties;
> import javax.servlet.jsp.JspException;
> import javax.servlet.jsp.JspTagException;
> import java.util.Random;
> public class DwRollTag extends ExTagSupport {
>  
>     static LocalStrings ls = 
> LocalStrings.getLocalStrings(TestHtmlTag.class);
>     protected String url = null;
>     protected String imgid = null;
>     protected String image = null;
>     protected String imageOut = null;
>  
>     public void setUrl(String url) {this.url = url;}
>     public void setImgid(String imgid) {this.imgid = imgid;}
>     public void setImage(String image) {this.image = image;}
>     public void setImageOut(String imageOut) {this.imageOut = 
> imageOut;}
>  
>  
>     public int doStartTag() throws JspException{
>  
>             if(null==url){url = "";}
>             if(null==image){image = ""; imageOut="";}
>             if(imgid == null){ imgid = getRandom();}
>             if(imageOut == null){imageOut = getImageOut(image);}
>             System.err.println(" image :" +  image + ", url : 
> " + url + ", imgid : " + imgid+ ", imageOut : " + imageOut);
>  
>         try {
>             pageContext.getOut().print(getImageRoll(url, 
> imgid, image, imageOut));
>         } catch(java.io.IOException ioe) {
>  
>             // User probably disconnected ...
>             log(ls.getStr("error"), ioe);
>             throw new JspTagException(ls.getStr("error"));
>         }
>  
>         return SKIP_BODY;
>     }
>  
>     protected String getRandom(){
>         Random wheel = new Random() ;
>         int unique = ( wheel.nextInt() & Integer.MAX_VALUE ) 
> %900000 + 100000 ;
>         return "" + unique;
>     }
>  
>             /**
>  * short version of getImageRoll, locationOut is named form 
> the location in + a "_over" just
>  *  before the file extention
>  *
>  * @param name
>  * @param locationIn
>  * @return
>  */
>     public String getImageOut(String image){
>             String imageOut;
>             int length = image.length();
>             int dot = image.lastIndexOf(".");
>             String first = "";
>             String last = ".gif";
>             if(dot!=-1){
>             first = image.substring(0,dot);
>             last = image.substring(dot, length);
>         }
>             imageOut = first+"_over"+last;
>             return imageOut;
>             }
>  
> /**
>  * getImageRoll return a typical rollover statement used by a 
> standard javascript function "changeImage()"
>  * @param name
>  * @param locationIn
>  * @param locationOut
>  * @return
>  */
>     public String getImageRoll(String url,
>                                 String imgid,
>                                 String image,
>                                 String imageOut){
>  
>         String retString = "<a href=\""+url+"\" 
> onMouseOut=\"MM_swapImgRestore()\"
> onMouseOver=\"MM_swapImage('"+imgid+"','','"+imageOut+"',1)\"><img
> name=\""+imgid+"\" border=\"0\" src=\""+image+"\"></a>";
>         return retString;
>     }
>  
>  
>      protected void clearProperties(){
>         url = null;
>         imgid = null;
>         image = null;
>         imageOut = null;
>         super.clearProperties();
>     }
>  
> }
>  
>  
>  
> tks 
>  
> E. L.
> etienno@sympatico.ca
>  
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message