[JBoss Seam] - Re: Download binary files
by MSchmidke
Hummm.
I removed the things I do not understand (as mentioned, beginRequest and endRequest). With this, I was able to remove BypassInterceptors, and without BypassInterceptors I can have injected my hibernate session.
At the first sight, it works perfectly. Of course, I don't know if I am breaking something in the interns of seam or if I am creating memory leaks or whatever.
| @Startup
| @Scope(ScopeType.APPLICATION)
| @Name("dateidownload")
| public class Dateidownload extends AbstractResource {
| @In
| Session session;
|
| @Override
| public void getResource(HttpServletRequest request,
| HttpServletResponse response) throws ServletException, IOException {
| // ServletLifecycle.beginRequest(request);
| try {
| String id = request.getQueryString();
| Anhang_Dokument ad = (Anhang_Dokument) session.get(
| Anhang_Dokument.class, Long.parseLong(id));
| if (ad == null)
| throw new ObjectNotFoundException(id);
| response.setHeader("Cache-Control", "no-store");
| response.setHeader("Pragma", "no-cache");
| response.setDateHeader("Expires", 0);
| response.setContentType(ad.getDatei().getMimeType());
| response.getOutputStream().write(ad.getDatei().getDaten());
| response.getOutputStream().flush();
| response.getOutputStream().close();
| } catch (Exception e) {
| response.sendError(HttpServletResponse.SC_NOT_FOUND);
| return;
| } finally {
| // ServletLifecycle.endRequest(request);
| }
| }
|
| @Override
| public String getResourcePath() {
| return "/download";
| }
|
| }
|
There are other things in CaptchaImage I don't understand, for example the meaning of @Startup and @Install together. But as told before, I simply deleted things I did not understand, and for the moment, it works ...
Marcus.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109888#4109888
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109888
17 years, 1 month