Since it starts with a leading slash, it will always be
http://localhost:8080/av.

That assumes your app is deployed as the root web application.

The only time it would break is if your app was not deployed as the root web
application, as might happen if your servlet container is deploying multiple
JARs.

At that point, the URI of your servlet becomes /context/av.

You could write a simple component that dynamically generates the <img> tag,
including the URL.  You would inject the Request object, in order to get the
context path.  Something like:

public class MyImage {
  @Inject
  private Request _request;

  @Parameter(required=true)
  private String _path;

  boolean beginRender(MarkupWriter writer)
  {
     String fullPath = _request.getContextPath() + "/av";

     writer.element("img", "src", fullPath).end();


     return false; // don't render body
  }
}


Usage:

<t:myimage path="literal:mypic.jpg"/>

.... that's from memory and some of the details are probably broken, but
that the gist of it.  Creating components is your primary problem solving
technique in Tapestry, and T5 makes it even easier to create components.

On 10/2/07, Angelo Chen <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> I have a servlet used with my T5 app, its job is to return an image from
> file system, the url-pattern is:
> <url-pattern>/av</url-pattern>
> in the template I have to refer it as:
> < img src="http://localhost:8080/av?fid=mypic.jpg"; / >
> this works, but if I deploy it, i have to update the server name, if I
> just
> use "/av?fid=mypic.jpg", it will not work as it might be appended to other
> URLs. any idea how to take care of this? Thanks,
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-using-servlet-tf4555798.html#a13001997
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Reply via email to