Servlets, Apache JServ and gcj/libgcj
Joerg Brunsmann
joerg.brunsmann@FernUni-Hagen.de
Sun Nov 21 07:18:00 GMT 1999
Hi,
during compilation and execution of a servlet with gcj/libgcj
I encountered the following problems:
1. Get Apache JServ 1.0 from http://java.apache.org
2. Get Java Servlet Development Kit 2.0 from
http://java.sun.com/products/servlet/download.html
3. Unpack the jar file which contain the compiled
class files for jsdk (lib/jsdk.jar)
4. Remove these classes:
sun/servlet/ServletLoader.class
sun/servlet/http/HackURLConnection.class
sun/servlet/http/HttpServer.class
sun/servlet/http/HttpServerHandler.class
[They need guessContentTypeFrom* from URLConnection which
aren't available yet]
5. Edit org/apache/jserv/JServUtils.java and
remove the line
return "ISO-8859-1";
with
return "8859_1";
This is needed because otherwise you get this error:
[21/11/1999 15:47:06:869] (ERROR) ajp11: Servlet Error:
java.io.UnsupportedEncodingException: ISO-8859-1
(java.lang.ClassNotFoundException: gnu.gcj.convert.Output_ISO-8859-1):
ISO-8859-1 (java.lang.ClassNotFoundException: gnu.gcj.convert.Output_ISO-8859-1)
6. Compile the JServ java files.
7. Copy this servlet into the base dir
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class start extends HttpServlet {
public void init(ServletConfig config) throws ServletException{ }
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("Hello world");
}
}
8. Download the makefile
http://www.informatik.fernuni-hagen.de/import/pi3/joerg/makefile
9. Compile
$ make prepare; make ; make app
$ ./JServ /usr/local/apache/conf/jserv.properties
Have fun,
Jörg
P.S.: Since I'm a total idiot can someone please explain, why
the libcj ServerSocket implementation complains about
Exception creating the server socket: java.net.BindException: SocketImpl.bind: Error 0
after stopping the JServ servlet engine with Ctrl-C wheras the
same program executed with a java vm starts again without
complaining. Netstat says that the state is TIME_WAIT.
More information about the Java
mailing list