This is the java example I'm trying to duplicate:
http://www.simpleframework.org/doc/tutorial/tutorial.php
import org.simpleframework.http.core.Container;
import org.simpleframework.transport.connect.Connection;
import org.simpleframework.transport.connect.SocketConnection;
import org.simpleframework.http.Response;
import org.simpleframework.http.Request;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.io.PrintStream;
public class HelloWorld implements Container {
public void handle(Request request, Response response) {
PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.set("Content-Type", "text/plain");
response.set("Server", "HelloWorld/1.0 (Simple 4.0)");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
body.println("Hello World");
body.close();
}
public static void main(String[] list) throws Exception {
Container container = new HelloWorld();
Connection connection = new SocketConnection(container);
SocketAddress address = new InetSocketAddress(8080);
connection.connect(address);
}
}
On Sat, Jan 28, 2012 at 6:33 AM, Joe Bogner <[email protected]> wrote:
>
> I'm trying to write a simple java web server using the simpleframework. I'm
> close, but I process anything in the method handler:
>
> (de handler (request response) (java response 'close))
> (setq cont (interface "org.simpleframework.http.core.Container" 'handle
> handler))
> (setq con (java "org.simpleframework.transport.connect.SocketConnection" T
> cont))
> (setq addr (java "java.net.InetSocketAddress" T 8005))
> (java con 'connect addr)
>
> When I run this and then curl http://localhost:8005 I get the following
> exception:
>
> java.lang.IllegalAccessException: Class PicoLisp$Number can not access a
> member
> of class org.simpleframework.http.core.ResponseEntity with modifiers "public"
>
> I've tried every other method I can think of from this doc:
> http://www.simpleframework.org/doc/javadoc/index.html
>
> If I intentionally put a missing method in, it correctly reports it:
> (de handler (request response) (java response 'close2))
> : !? (java response 'close2)
> java.lang.NoSuchMethodException: close2
>
> If my handler is this, I get a response.
> (de handler (request response) (prinl response))
> : HTTP/1.1 200 OK
>
> I need to be able access the request/response to process it. I am not sure if
> I need to use javac because of the interface but then I'm not sure how I'd
> add picolisp code to process the request/response.
>
> Thanks for any help
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe