KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > webapp > servlet > ProcessImageServlet


1 package org.jbpm.webapp.servlet;
2
3 import java.io.IOException JavaDoc;
4 import java.io.OutputStream JavaDoc;
5
6 import javax.servlet.ServletException JavaDoc;
7 import javax.servlet.http.HttpServlet JavaDoc;
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9 import javax.servlet.http.HttpServletResponse JavaDoc;
10
11 import org.jbpm.db.JbpmSession;
12 import org.jbpm.graph.def.ProcessDefinition;
13
14 public class ProcessImageServlet extends HttpServlet JavaDoc {
15   
16     private static final long serialVersionUID = 1L;
17
18     protected void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
19         throws ServletException JavaDoc, IOException JavaDoc {
20     long processDefinitionId = Long.parseLong( request.getParameter( "definitionId" ) );
21     JbpmSession jbpmSession = JbpmSession.getCurrentJbpmSession();
22     ProcessDefinition processDefinition = jbpmSession.getGraphSession().loadProcessDefinition(processDefinitionId);
23     byte[] bytes = processDefinition.getFileDefinition().getBytes("processimage.jpg");
24     OutputStream JavaDoc out = response.getOutputStream();
25     out.write(bytes);
26     out.flush();
27     
28     // leave this in. it is in case we want to set the mime type later.
29
// get the mime type
30
// String contentType = URLConnection.getFileNameMap().getContentTypeFor( fileName );
31
// set the content type (=mime type)
32
// response.setContentType( contentType );
33
}
34 }
35
Popular Tags