- From: Anselm Baird-Smith <abaird@w3.org>
- Date: Sat, 6 Jul 1996 23:44:36 +0500
- To: "Mark I. Lubin" <mil@phys.physics.ucf.edu>
- Cc: www-jigsaw@w3.org
Mark I. Lubin writes:
> I went through FancyResource example in doc. Even I have
> some idea about the installation of the new resources, I would like to
> have some simple example for PostableResource, that I could modify.
> Say I want to have a Form (with method="POST"), from which the server
> fetching the data and then sending some response back. For instance, I
> write the string in the form that should be reversed on the server and
> the result sent back to the user.
Here is a simple shot at the ReverseString resource ( I haven't
compiled it, I will just try writing it). Lets' say we will put this
resource in class w3c.jigsaw.contrib.ReverseString, so here it goes:
-----
package w3c.jigsaw.contrib;
import java.util.*;
import w3c.jigsaw.http.*;
import w3c.jigsaw.forms.*;
public class ReverseString extends PostableResource {
public Reply handle(Request request, URLDecoder data)
throws HTTPException
{
String str = data.getValue("string");
if ((str == null) || str.equals("")) {
Reply reply = request.makeReply(HTTP.OK);
reply.setContent("reverse=[]");
return reply;
}
// Reverse the string (should be some other method, etc)
// You could ameliroate this alot, but that's not the point
char cs[] = new char[str.length()];
str.getChars(0, cs.length, cs, 0);
char cr[] = new char[cs.length];
for(int i = 0 ; i < cs.length; i++)
cr[cs.length-1-i] = cs[i];
// Emit reply:
Reply reply = request.makeReply(HTTP.OK);
reply.setContent("reverse=["+new String(cr)+"]");
return reply;
}
public ReverseString() {
}
}
-----
AGain I have not compiled this code, and it's too late to try doing it
now. Howver, chances are good that it would run. If it doesn't let me
know !
You will then have to compile/install the resource, but you can follow
the tutorial here.
> Also since in Netscape3.0 there is communicatoin between
> HTML-Forms and Java-applets it would be useful to have a simple example
> for communication between Java-applet and Jigsaw( and maybe HTML-Form)
I have some ideas about this, but they are not for now...Basically
Jigsaw should have support for servlets (not the Jeeves kind of
servlets, but really small servers inside the server; which might be
the Jeeves kind, in fact, but with no HTTP in the way ...). For those
of you who have been that far in the code, I mean some enhancements to
the Client API (w3c.jigsaw.http.CLient, which should really be
w3c.jigsaw.daemon.client...).
Anselm.
Received on Saturday, 6 July 1996 23:44:41 UTC