  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Possible to send an image from a servlet to Shockwave? | Possible to send an image from a servlet to Shockwave? 2005-04-28 - By Darrin Smith
Back I have an application where I need to load a 3D image based on a user selection that takes place in a JSP.
The Flash/Shockwave plugin will have a value that relates to a servlet that will load the image and send it back to the plugin.
So far, I can get the plugin to load just fine and contact the servlet which loads the image and sends it back, but the Flash/Shcokcwave plugin never completes loading (just loops a progress bar saying that it is loading).
My question is, can dynamic loading to a Flash/Shockwave component be done from a servlet like this?
If so, can someone please point me to an example of what needs to be done to send the image back?
Here is what I am trying in the servlet that, although no exceptions are thrown and the file gets read in correctly, does not seem to provide the plugin what it needs. Can anyone see what I may be doing wrong?
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String ct=request.getParameter("contenttype");
if ((ct==null)||(ct.equals(""))) { ct="application/x-director"; }
try { ServletOutputStream out = response.getOutputStream(); response.setContentType(ct);
byte[] image = getImage();
if(image == null) { System.out.println("NULL IMAGE"); } else { System.out.println("Returning 3D image" ); }
out.write(image); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
private byte[] getImage() { byte[] result = null;
String fileLocation = "C:/Documents and Settings/Administrator/My Documents /Creator/Projects/MyApp/build/volc_hw.dcr"; File f = new File(fileLocation);
System.out.println("Trying to read from: " fileLocation);
result = new byte[(int)f.length()];
try { FileInputStream in = new FileInputStream(fileLocation);
//Read file into byte array in.read(result); } catch(Exception ex) { log("Exception caught: " ex.getMessage()); }
return result; }
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
<html> <!-- BEGIN WEBMAIL STATIONERY --> <head></head> <body> <!-- WEBMAIL STATIONERY noneset --> <DIV>I have an application where I need to load a 3D image based on a user selection that takes place in a JSP.<BR><BR>The Flash/Shockwave plugin will have a value that relates to a servlet that will load the image and send it back to the plugin. <BR><BR>So far, I can get the plugin to load just fine and contact the servlet which loads the image and sends it back, but the Flash /Shcokcwave plugin never completes loading (just loops a progress bar saying that it is loading). <BR><BR>My question is, can dynamic loading to a Flash /Shockwave component be done from a servlet like this? <BR><BR>If so, can someone please point me to an example of what needs to be done to send the image back? <BR><BR>Here is what I am trying in the servlet that, although no exceptions are thrown and the file gets read in correctly, does not seem to provide the plugin what it needs. Can anyone see what I may be doing wrong?< /DIV> <DIV> </DIV> <DIV> <BR><BR>protected void processRequest(HttpServletRequest request, <BR> HttpServletResponse response) <BR> throws ServletException, <BR> IOException <BR>{ <BR><BR> String ct=request.getParameter( "contenttype"); <BR><BR> if ((ct==null)||(ct.equals(""))) <BR> { <BR > ct="application/x-director"; <BR> } <BR><BR> try <BR> { <BR> ServletOutputStream out = response.getOutputStream(); <BR> response.setContentType(ct); <BR><BR> byte[] image = getImage(); <BR><BR> if(image == null) <BR> { <BR> System.out.println( "NULL IMAGE"); <BR> } <BR> els e <BR> { <BR> System.out.println( "Returning 3D image" ); <BR> } <BR><BR> out .write(image); <BR> } <BR> catch (Exception e) <BR> { <BR> System.out.println(e.getMessage()); <BR> e .printStackTrace(); <BR> } <BR>} <BR><BR><BR>private byte[] getImage () <BR>{ <BR> byte[] result = null; <BR><BR> String fileLocation = "C:/Documents and Settings/Administrator/My Documents /Creator/Projects/MyApp/build/volc_hw.dcr"; <BR> File f = new File(fileLocation); <BR><BR> System.out.println("Trying to read from: " fileLocation); <BR><BR> result = new byte[(int)f .length()]; <BR><BR> try <BR> { <BR> FileInputStream in = new FileInputStream (fileLocation); <BR><BR> //R ead file into byte array <BR> in.read(result); <BR> } <BR> catch(Exception ex) <BR> { <BR> log("Exception caught: " ex.getMessage()); <BR> } <BR> </DIV> <DIV> return result; <BR>} <BR></DIV> <!-- END WEBMAIL STATIONERY -->
</body> </html> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff SERVLET-INTEREST". <p> Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html <p>
|
|
 |