----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
------------- Begin Forwarded Message -------------
Date: Mon, 14 Aug 2000 18:04:18 -0400 (EDT)
From: George Wu <wu>
Subject: NoClassDefFoundErr error in servlet
To: [EMAIL PROTECTED]
Mime-Version: 1.0
Content-MD5: B/IaVZDaI8BgtGLbZmpP+Q==
------------- Begin Forwarded Message -------------
Date: Mon, 14 Aug 2000 18:01:33 -0400 (EDT)
From: George Wu <wu>
To: [EMAIL PROTECTED]
Mime-Version: 1.0
Content-MD5: EVCxbs4tD91w1B5uvBqzQw==
Hi, all
I am having a problem with a Java Servlet code. I kept getting
"NoClassDefFoundErr". I used a third party class file downloaded over internet.
I include the path of the class file in $CLASSPATH. compiled with it without
any error. But when I open it in netscape, I got the above error.
Then I replaced the body of subroutine doGet with the body of another class. It
worked.
I think it because of the third party class. I zipped the whole directory into a
zip file and included the path of zip file in $CLASSPATH, it still didn't work.
I am using Apache web server with JServ.
This is the code with problem, Acme.JPM.Encoders.GifEncoder is the third party
class which is freely available from www.acme.com.
import java.io.*;
import java.awt.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Acme.JPM.Encoders.GifEncoder;
public class HelloWorldGraphics extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();
Frame frame = null;
Graphics g = null;
try {
frame = new Frame();
frame.addNotify();
Image image = frame.createImage(400,60);
g = image.getGraphics();
g.setFont(new Font("Serif",Font.ITALIC,48));
g.drawString("Hello World!", 10,50);
res.setContentType("image/gif");
GifEncoder encoder = new GifEncoder(image, out);
encoder.encode();
}
finally {
if (g!=null) g.dispose();
if (frame != null ) frame.removeNotify();
}
}
}
This is the code that works.
import java.io.*;
import java.awt.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Acme.JPM.Encoders.GifEncoder;
public class HelloWorldGraphics extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
out.println("<BODY>");
out.println("<BIG>HELLO WORLD<BR></BIG>");
out.println("Hey,JServ is working on Apache Web Server!");
out.println("</BODY></HTML>");
}
}
Thanks in advance,
George Wu
Application Analyst
Dept. of Human Genetics
Memorial Sloan Kettering Cancer Center
(212)639-2850
[EMAIL PROTECTED]
------------- End Forwarded Message -------------
George Wu
Application Analyst
Dept. of Human Genetics
Memorial Sloan Kettering Cancer Center
(212)639-2850
[EMAIL PROTECTED]
------------- End Forwarded Message -------------
George Wu
Application Analyst
Dept. of Human Genetics
Memorial Sloan Kettering Cancer Center
(212)639-2850
[EMAIL PROTECTED]
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search Archives:
<http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]