You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Thomas Rickal, IOP Unternehmensberatung GmbH" <t....@iop.de> on 2001/11/16 09:38:28 UTC

Is Tomcat 4.0.1 taglib integration buggy?

Hi again,

i' am trying to upgrade from Tomcat 3.2.3/ Apache 1.3.19 to Tomcat
4.0.1/ Apache 1.3.19 on Linux.

All the urls in the jsps of my application are rewritten by a
UrlTag. The UrlTag Class takes the url between the tags and rewrites
it if necessary.

It works with Tomcat 4.0.1 if the url is placed in the jsp file
statically. It works not if the url is get by using the "get"-method
of a bean.

In Tomcat 3.2.3 it worked fine in both cases. Maybe this is a Tomcat
4.0.1 bug? Who can help?

Thomas


Example:

### example.jsp ###

<A href="<myLib:url><%= myBean.getURL() %></myLib:url>">text</A>


### output Tomcat 3.2.3 (right) ###

<A href="http://localhost/target.jsp">text</A>


### output Tomcat 4.0.1 (wrong) ###

<A href="<%= myBean.getURL() %>">text</A>


### example.tld ###

<tag>
  <name>url</name>
  <tagclass>de.iop.webrun.shared.taglib.UrlTag</tagclass>
  <bodycontent>tagdependent</bodycontent>
  <info>rewrite url</info>
</tag>


### UrlTag-Code ###

import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.IOException;

public class UrlTag extends BodyTagSupport
{
  public int doAfterBody() throws JspException
  {
    BodyContent bodyContent = getBodyContent();
    String baseURL          = bodyContent.getString();
    bodyContent.clearBody();
    try
    {
      HttpServletResponse response = (HttpServletResponse)
pageContext.getResponse();
      String encodedURL = response.encodeURL(baseURL);
      this.getPreviousOut().print(encodedURL);
    }
    catch(IOException e)
    {
      throw new JspTagException("I/O exception " + e.getMessage());
    }
    return SKIP_BODY;
  }
}



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


AW: Is Tomcat 4.0.1 taglib integration buggy? No!

Posted by "Thomas Rickal, IOP Unternehmensberatung GmbH" <t....@iop.de>.
Hi,

i fixed it. I had to change bodycontent from tagdependent to JSP in
my tld and to clear the work directory.

Thanx to all.

Thomas



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


AW: Is Tomcat 4.0.1 taglib integration buggy?

Posted by "Thomas Rickal, IOP Unternehmensberatung GmbH" <t....@iop.de>.
Hi David,

i tried to return EVAL_BODY_TAG but then tomcat was not able to
serve the page. An infinite amount of kilobytes was produced as
response.

I intensively used taglibs in the project to encapsulate und reuse
view logic for several jsps. It isn't a good idea to place the code
directly in my jsps. I could do it for the url-rewriting but i
should not do it for the other components.

Thomas



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Is Tomcat 4.0.1 taglib integration buggy?

Posted by David Cassidy <dc...@hotgen.com>.
try

return EVAL_BODY_TAG

...

Why not just do

<%=  response.encodeURL( "/page/you/want/to/go/to.jsp" ) %>



David




"Thomas Rickal, IOP Unternehmensberatung GmbH" wrote:

>
>
> Hi again,
>
> i' am trying to upgrade from Tomcat 3.2.3/ Apache 1.3.19 to Tomcat
> 4.0.1/ Apache 1.3.19 on Linux.
>
> All the urls in the jsps of my application are rewritten by a
> UrlTag. The UrlTag Class takes the url between the tags and rewrites
> it if necessary.
>
> It works with Tomcat 4.0.1 if the url is placed in the jsp file
> statically. It works not if the url is get by using the "get"-method
> of a bean.
>
> In Tomcat 3.2.3 it worked fine in both cases. Maybe this is a Tomcat
> 4.0.1 bug? Who can help?
>
> Thomas
>
> Example:
>
> ### example.jsp ###
>
> <A href="<myLib:url><%= myBean.getURL() %></myLib:url>">text</A>
>
> ### output Tomcat 3.2.3 (right) ###
>
> <A href="http://localhost/target.jsp">text</A>
>
> ### output Tomcat 4.0.1 (wrong) ###
>
> <A href="<%= myBean.getURL() %>">text</A>
>
> ### example.tld ###
>
> <tag>
>   <name>url</name>
>   <tagclass>de.iop.webrun.shared.taglib.UrlTag</tagclass>
>   <bodycontent>tagdependent</bodycontent>
>   <info>rewrite url</info>
> </tag>
>
> ### UrlTag-Code ###
>
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.jsp.tagext.*;
> import javax.servlet.jsp.*;
> import java.io.IOException;
>
> public class UrlTag extends BodyTagSupport
> {
>   public int doAfterBody() throws JspException
>   {
>     BodyContent bodyContent = getBodyContent();
>     String baseURL          = bodyContent.getString();
>     bodyContent.clearBody();
>     try
>     {
>       HttpServletResponse response = (HttpServletResponse)
> pageContext.getResponse();
>       String encodedURL = response.encodeURL(baseURL);
>       this.getPreviousOut().print(encodedURL);
>     }
>     catch(IOException e)
>     {
>       throw new JspTagException("I/O exception " + e.getMessage());
>     }
>     return SKIP_BODY;
>   }
> }
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>