Reputation: 4991
Is there anyway to add resources to a web application using JSF programmatically? This would involve adding files in the resource folder (or any of it subfolders). I want to add a picture that can be treated as a resource so I display it with
<h:graphicImage name="name of the resource i create" library="subfolder under resources" />
Upvotes: 0
Views: 907
Reputation: 1108722
You don't want to write to web content programmatically. It will all get lost whenever you redeploy the webapp.
Just save it to disk or DB using FileOutputStream
or PreparedStatement#setBinaryStream()
and then have a servlet which gets an InputStream
of it from disk or DB using FileInputStream
or ResultSet#getBinaryStream()
respectively and then writes it to the OutputStream
of the response along a proper set of HTTP response headers. Finally just call that servlet by its URL, along with the unique resource identifier or filename as request parameter or pathinfo.
Upvotes: 2