Using your suggestion I've done this way :
/**
 * @tapestry.inject property="webContext" type="object"
object="tapestry.globals.WebContext"
 */
public abstract class NewsTemplate extends BasePage {
    public abstract WebContext getWebContext();
    public String getNewsContent(){
        URL resourceUrl =
getWebContext().getResource("/myGeneratedFileName.txt");
        // get the content from URL
    }
}

Thanks a lot guys. I won't use the Geoff approach jast because I'm on
Tap4 and getRequestCycle().getRequestContext() is deprecated.
Geoff tanks a lot anyway.

Paolo


On 8/29/05, Darío Vasconcelos <[EMAIL PROTECTED]> wrote:
> And you need access to ServletContext because you need getRealPath()
> or something like that?
> 
> In TP4, apparently you just need to inject
> tapestry.globals.HttpRequest and call
> getSession().getServletContext(), but this creates a session which
> would be a problem for stateless applications.
> 
> http://article.gmane.org/gmane.comp.java.tapestry.user/23445/match=servletcontext
> 
> Hope it helps,
> 
> 
> On 8/29/05, Paolo Donà <[EMAIL PROTECTED]> wrote:
> > Hi guys,
> > I'm migrating a JSP app to tapestry4.
> > How can I migrate this simple JSP code to tapestry?
> >
> > <% String dinamicallyGeneratedFileName = request.getParameter(..); %>
> > <html>
> > <body>
> >    MY HEADER HERE
> >    <jsp:include page="<%=dinamicallyGeneratedFileName"%>.txt"/>
> >    MY FOOTER HERE
> > </body>
> > </html>
> >
> > My text files are stored somewere on the context root, but I cannot
> > define assets for them, because they are put there by the customer via
> > ftp and their names are unpredictable.
> > I would just need the ServletContext object inside my tapestry page
> > but don't know how to get it. I could then call
> > ServletContext.getResource() or getResourceAsStream() to load the file
> > I need. I couldn't find a solution.
> >
> > Can someone point me to the right direction?
> >
> > Thanks a lot.
> > Paolo
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> --
> I have enough money to last me the rest of my life, unless I buy something.
>     Jackie Mason
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to