Skip to main content

JSF 2.2 upload and GlassFish directory

No replies
Antonio Goncalv...
Joined: 2011-01-04
Points: 0

Hi all,

Environment : Java SE 7 / Mac OS X / GlassFish 4.0.1-b03.

I want to use the new JSF 2.2 file upload to upload mp4 videos and then be
able to watch them with an HTML5 tag. The JSF page uses the new
as follow :

The backing bean uses the Part interface. The upload method writes the MP4
file using the write method :

public class TalkBean implements Serializable {

private Talk talk;
private Part video;

public String upload() throws IOException {
video.write( talk.getId() + ".mp4");
return null;

The problem with the write method is that the file is stored under the
temporary directory :
$GLASSFISH_HOME/glassfish/domains/domain1/generated/jsp/sampleJSFVideo. If
I try to change the file location :

video.write("*/Users/antoniombp/Documents/*" + talk.getId() + ".mp4");

GlassFish throws an exception because it concats both directories :
(No such file or directory)

Only if I navigate down through the directories I manage to change
locations :

video.write("*../../../*" + talk.getId() + ".mp4");

But the final question really is where do I upload my MP4 files so I can
view them from my web application ?