Marilen Corciovei a écrit :
Hello,

@InjectObject("service:tapestry.globals.ServletContext")
public abstract ServletContext getServletContext();
Yes, that's it. Thanks Len.

And Please, how to without annotation ?

I'm looking in Tapestry Javadoc for some static method and I could not find one.

Cyrille

...
String imageDir = getServletContext().getRealPath("images");
...

Len
www.len.ro <http://www.len.ro>


On Thu, 2006-12-21 at 10:02 +0100, Cyrille37 wrote:
Hello,
Sure it is a beginner question, but I'm a beginner :o)

I would like to read a file which is located in the web root folder, and put it in a String.
I had a look around the Internet and found some tricks :

A la "Servlet" :
ServletContext theApplicationsServletContext = (ServletContext) this.getExternalContext().getContext(); String realPath = theApplicationsServletContext.getRealPath("/resources/images");
File file = new File(realPath + File.separatorChar + justFileName);

A la "Rife" :
import com.uwyn.rife.tools.FileUtils;
URL resource = getClass().getClassLoader().getResource("model/WordList.txt");
final String wordlist = FileUtils.readString(resource);

Please could you tell me what are methods and usages with Tapestry ?

Thanks
cyrille

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




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

Reply via email to