Hi Michael,
I am working on a project that does something similar.
Please correct me if I did not address your problem.
I have sample codes here. Check it out. It works for my test web page (but is far away
from my real objective)
public class TestServlet extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse resp){
try{
ServletOutputStream toClient = resp.getOutputStream();
FileInputStream fromFile = new FileInputStream("c:\\help.gif");
byte[] array = new byte[fromFile.available()];
int len = fromFile.read(array);
toClient.write(array);
toClient.close();
fromFile.close();
}catch (Exception e){
ServletContext srvctx = getServletContext();
srvctx.log("Exception by TestServlet", e);
}
}
}
Of course...you might want to add any appropriate method call (e.g setting content
type)
Godspeed,
Lee Seng aka echo5
>>Date: Mon, 26 Feb 2001 11:05:24 -0500
>>From: A mailing list for discussion about Sun Microsystem s Java Servlet API
>Technology. <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>CC:
>>Subject: Re: Print Image to client
>>
Michael Weller wrote:
> Hi everybody!
>
> I have a servlet that gets a filename (of an image) as parameter, loads that
> image, creates a thumbnail and sends it back to the client.
> I want the use the servlet in my html pages like this: <img
> src="http://host/servlet/Thumbnail?file=image.jpg">.
> The upload of the image and the scaling works fine but I have a problem with
> sending the image to the client:
> I have a javax.media.jai.RenderedOp-object and need to write it to the
> client as something that has the content type image/jpeg. How do I do that?
>
> (Maybe this question or a similar one was answered before: I couldn't search
> the archives!!!)
>
> Thanks in advance.
>
> Michael Weller
> [...]
Hi :-)
from a book "Java Servlet Programming" (Jason Hunter, first Edition,
ISBN: 1-56592-391-X"), from P159, there is a sample of:
- how to "process" an image with GifEncoder(from www.acme.com)
in Servlet-side
- how to send an image to client from Servlet
BTW, I find an WbmpEncoder in the following link:
http://www.alphaworks.ibm.com/aw.nsf/techreqs/wbmpencoder
It is similar with GifEncoder.
Bo
Feb.26, 2001
___________________________________________________________________________
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
_________________________________________________
The simple way to read all your emails at ThatWeb
http://www.thatweb.com
___________________________________________________________________________
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