Ref: Re: [Opensource] Really strange bug when using Expresso in Tomcat
4.1
Raul DAVIDOVICH
R.DAVIDOVICH at caconcology.com
Fri Oct 3 02:37:51 PDT 2003
Hello Michael,
In fact, I thought I had cancelled the email on time, but obviously I did
not..
Just this action didn't correct the issue.. I thought I did because I
tested it on Tomcat 4.0 instead of 4.1! (I forgot to switch the execution
configuration in JBuilder).
To actually correct it (tested with the right Tomcat 4.1 I triple checked
that) I had to do two things.; First to inverse the content of the
doStartTag and doEndTag methods and change the return value, EVAL_PAGE for
doEndTag and EVAL_BODY_INCLUDE for doStartTag, and second to add one
initialization line to the doStartTag method: "oneElement = null;"
Here is the code for the two methods
...
/**
* Standard doEndTag.
*
* @return int
* @throws javax.servlet.jsp.JspTagException
*/
public int doEndTag() throws JspTagException {
//RETURN EVAL_PAGE ON doEndTag()
return EVAL_PAGE;
}
/**
* Standard doStartTag.
*
* @return int
* @throws javax.servlet.jsp.JspTagException
*/
public int doStartTag()
throws javax.servlet.jsp.JspTagException {
nameToUse = name;
typeToUse = type;
controllerElementToUse = controllerElement;
getControllerResponse();
// VERY IMPORTANT LINE!! WITHOUT THIS INITIALIZATION THE TAG READS ALWAYS
THE FIRST Output REFERENCED
oneElement = null;
try {
//If the controllerElement and type have been specified, this
takes precedence over parent.
if (type != null && !"".equals(type) &&
controllerElementToUse != null &&
!"".equals(controllerElementToUse)) {
if ("INPUT".equals(typeToUse)) {
oneElement = ctlrResp.getInput(controllerElementToUse);
} else {
oneElement =
ctlrResp.getOutput(controllerElementToUse);
}
}
if (oneElement == null) {
//we did not have attributes specified in the tag.
//Check to see if we have an ancestor
InputTag ancestorInput = (InputTag) getAncestor(
"com.jcorporate.expresso.ext.taglib.InputTag");
OutputTag ancestorOutput = (OutputTag) getAncestor(
"com.jcorporate.expresso.ext.taglib.OutputTag");
boolean ancestorFoundFlag = false;
if (ancestorInput != null) {
ancestorFoundFlag = true;
typeToUse = "INPUT";
} else if (ancestorOutput != null) {
ancestorFoundFlag = true;
typeToUse = "OUTPUT";
}
if (ancestorFoundFlag) {
if ("INPUT".equals(typeToUse)) {
// controllerElementToUse = ancestorInput.getName
();
oneElement = ancestorInput.getInput();
} else {
//controllerElementToUse = ancestorOutput.getName
();
oneElement = ancestorOutput.getOutput();
}
}
}
if (oneElement != null) {
attributeContent = oneElement.getAttribute(nameToUse);
} else {
attributeContent = "ATTRIBUTE NOT FOUND";
}
JspWriter writer = pageContext.getOut();
writer.print(attributeContent);
} catch (Exception e) {
throw new JspTagException("AttributeTag Error: " + e.getMessage
());
}
//RETURN EVAL_BODY_INCLUDE ON deStartTag()
return EVAL_BODY_INCLUDE;
} /* doEndTag() */
...
Sorry for my wrong email before.
Regards
---------------------------------------------------
Raul Davidovich
Responsable Informatique
Cvitkovic & Associés Consultants
(33) 1 45 15 40 68
(33) 1 45 15 40 41 Fax
-------------------------------------------------------
http://www.caconcology.com
>Michael,
>
>I found it!!
Excellant News. Thank you for the rundown. Just to double-check, most of
those tags should have SKIP_BODY in them, correct?
-Mike
>in JSP 1.2(tomcat 4.1) the default behaviour for custom tags is to reuse
>them, which improves performance, whereas in JSP 1.1 (tomcat 4.0) it
>constructs a new object each time the tag is called.
>
>According to the guidelines, all the private invocation-specific state
>should be in the doStartTag() method rather than in the constructor, and
>AttributeTag has no doStartTag() method, therefore it doesn't get reset.
>
>Simply by adding the following lines to AttributeTag.java the problem was
>gone:
>
>...
>/**
>* Standard doStartTag.
>*
>* @return int
>* @throws javax.servlet.jsp.JspTagException
>*/
>public int doStartTag() throws JspTagException {
> return EVAL_BODY_INCLUDE;
>}
>...
>
>
>
>Here are some docs about this:
>http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html
>
>http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html
>
>http://jakarta.apache.org/taglibs/guidelines.html
>
>
>I checked and this method is missing too in the following tags, but I
don't
>know wether or not it's neccesary for them:
>
>Back
>ContentTag
>DBDescription
>LabelTag
>Login
>MessageUtil
>UserName
>ExpressoTagSupport
>ExpressoBodyTagSupport
>
>
>
>
>
>Thank you very much for your help!
>
>
>Best regards,
>
>Raul Davidovich
>
>
> >>At 06:57 AM 9/18/2003, you wrote:
> >>>I found out a very strange behaviour when running expresso on Tomcat
>4.1,
> >>>which doesn't come up in tomcat 4.0.
>
>
> >>Hi Raul!
>
> >>What you're hitting is a tag reuse problem. The controller element
being
> >>used is still reflecting the initial one even though through the reset
of
> >>the tags before use in the next use of the tag.
>
> >>I thought this was fixed for 5.3, and POSSIBLY later versions of 5.0.X
> >>[maybe >.0.3??] but I can't be sure. I just remember coming across
this
> >>and a fix posted by somebody on the list.
>
> >>What's your version you're encountering this. We'll have to figure out
> >>what's not getting reset between instance uses.
>
> >> -Mike
>
>
>
>
> >The symptom is OutputTags in JSP don't get refreshed when the transition
> >leads to the same page with updated outputs.
> >
> >I've tracked down the problem up to the level of AttributeTag. What
>happens
> >here is that because of some strange reason, the variable "oneElement"
in
> >the AttirbuteTag object always points to the output object created the
> >first time the page was built, and it doesn't get updated the following
> >times, while all other references to this output object point now to the
> >new one (myOutput in MYController, and oneOutput in OutputTag).
> >
> >So for example we have page a.jsp, which shows the output of the state
> >promptAState from MyController.
> >This page has an "again" button which will lead to the AState of
> >MyController, and this state will give it's results again to
promptAState,
> >who will show them in an output object, and prompt for a new value and
> >"again" or "ok".
> >
> >Let's say that the first time, the output was "123", and the second time
>it
> >was "456". In tomcat 4.0 this works fine, but in tomcat 4.1, it will
still
> >show "123", no matter how many times I press "again". (I insist that the
> >new output object is created and filled up with the right values, and
> >OutputTag points to the right object)
> >
> >
> >Any clues?
> >
> >
> >Best regards
> >
> >
> >Raul Davidovich
> >
> >
> >
> >
> >_______________________________________________
> >Opensource mailing list
> >Opensource at jcorporate.com
> >http://mail.jcorporate.com/mailman/listinfo/opensource
> >Archives: http://mail.jcorporate.com/pipermail/opensource/
>
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/
>
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/
_______________________________________________
Opensource mailing list
Opensource at jcorporate.com
http://mail.jcorporate.com/mailman/listinfo/opensource
Archives: http://mail.jcorporate.com/pipermail/opensource/
More information about the Opensource
mailing list