webtier@glassfish.java.net

Re: creating a file from managed bean.

From: <webtier_at_javadesktop.org>
Date: Tue, 17 Aug 2010 00:00:28 PDT

Hello samanosuke31,

to my knowledge, the servlet standard defines a way to get the path of a webapp on the disk.

http://download.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

i.e. if I'm not mistaken you should be able to get the path on disk via

[code]servletContext.getRealPath("/");[/code]

In order to fetch the servletContext from Faces, you can do

[code]ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext();[/code]

I hope this helps,

Manuel
[Message sent by forum member 'manuelbernhardt']

http://forums.java.net/jive/thread.jspa?messageID=480355