Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Servlets and image processing with GNU/Linux

0 views
Skip to first unread message

Lionel Peron

unread,
Sep 13, 2000, 10:06:51 AM9/13/00
to
This servlet can display an image if it run under MS NT server. But it does
not work under GNU/Linux RedHat 6.0 server.
Does anybody knows about this problem ?
Is it possible to a servlet to read a jpeg image into a frame, modify it,
and then return an encoded jpg stream as response with Linux.

Regards.
Lionel.

Code :
import javax.swing.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class JpegDisplay extends HttpServlet {

File file = new File("/home/mon_image.jpg");

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();

ImageIcon imgIcon = new ImageIcon(this.getFileToByteArray(file));

res.setContentType("image/jpeg");
out.write(this.getFileToByteArray(file));
}

private byte[] getFileToByteArray(File pFile)
{
byte[] tmpBuffer = null;
if (pFile!=null)
{
FileInputStream fileStream = null;
try{
fileStream = new FileInputStream( pFile );
} catch (java.io.FileNotFoundException e) {
System.err.println("WARNING : File not found");
}
tmpBuffer = new byte[ (int)pFile.length() ];
try{
fileStream.read(tmpBuffer);
}catch (java.io.IOException e) {
tmpBuffer = null;
System.err.println("WARNING : Impossible to translate file
in byte[]");
}
}
return tmpBuffer;
}
}

error sous linux :

java.lang.NoClassDefFoundError: sun/awt/motif/MToolkit at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:327)
at org.apache.jserv.JServConnection.run(JServConnection.java:197)
at java.lang.Thread.run(Thread.java:479)

0 new messages