Re: Possible to send an image from a servlet to Shockwave?
"Mr. Cristian D. Romanescu" <[email protected]> Wed, 4 May 2005 09:12:43 +0300
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
Have you tried to flush the buffer after writing the data?
out.flushBuffer(); ...
Darrin Smith wrote:
> 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");
> }
> els e
> {
> 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);
>
> //R ead file into byte array
> in.read(result);
> }
> catch(Exception ex)
> {
> log("Exception caught: " ex.getMessage());
> }
>
> return result;
> }
> ___________________________________________________________________________
> To unsubscribe, send email to [email 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
>
___________________________________________________________________________
To unsubscribe, send email to [email 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