Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
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
Reply:     1     2     3  

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>&nbsp;</DIV>
<DIV>&nbsp;<BR><BR>protected void processRequest(HttpServletRequest request,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; HttpServletResponse response) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throws ServletException,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; IOException <BR>{ <BR><BR>&nbsp; String ct=request.getParameter(
"contenttype"); <BR><BR>&nbsp; if ((ct==null)||(ct.equals(""))) <BR>&nbsp; { <BR
>&nbsp; ct="application/x-director"; <BR>&nbsp; } <BR><BR>&nbsp; try <BR>&nbsp;
{ <BR>&nbsp;&nbsp;&nbsp; ServletOutputStream out = response.getOutputStream();
<BR>&nbsp;&nbsp;&nbsp; response.setContentType(ct); <BR><BR>&nbsp;&nbsp;&nbsp;
byte[] image = getImage(); <BR><BR>&nbsp;&nbsp;&nbsp; if(image == null)&nbsp;
<BR>&nbsp;&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(
"NULL IMAGE"); <BR>&nbsp;&nbsp; } <BR>&nbsp;&nbsp; els
e <BR>&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(
"Returning 3D image" ); <BR>&nbsp;&nbsp;&nbsp; } <BR><BR>&nbsp;&nbsp;&nbsp; out
.write(image); <BR>&nbsp;} <BR>&nbsp;catch (Exception e) <BR>&nbsp;{ <BR>&nbsp;
&nbsp;&nbsp; System.out.println(e.getMessage()); <BR>&nbsp;&nbsp;&nbsp; e
.printStackTrace();&nbsp; <BR>&nbsp; } <BR>} <BR><BR><BR>private byte[] getImage
() <BR>{ <BR>&nbsp;&nbsp;&nbsp; byte[] result = null; <BR><BR>&nbsp;&nbsp;&nbsp;
String fileLocation = "C:/Documents and Settings/Administrator/My Documents
/Creator/Projects/MyApp/build/volc_hw.dcr"; <BR>&nbsp;&nbsp;&nbsp; File f = new
File(fileLocation); <BR><BR>&nbsp;&nbsp;&nbsp; System.out.println("Trying to
read from: " fileLocation); <BR><BR>&nbsp;&nbsp;&nbsp; result = new byte[(int)f
.length()]; <BR><BR>&nbsp;&nbsp;&nbsp; try&nbsp;<BR>&nbsp;&nbsp;&nbsp;{ <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileInputStream in = new FileInputStream
(fileLocation); <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //R
ead file into byte array <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in.read(result);
<BR>&nbsp;&nbsp; } <BR>&nbsp;&nbsp; catch(Exception ex) <BR>&nbsp;&nbsp; { <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; log("Exception caught: " ex.getMessage());
<BR>&nbsp;&nbsp;&nbsp; }&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; 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>

©2008 junlu.com - Jax Systems, LLC, U.S.A.