Ahh, would that it were so simple..... To make a long story short, it
just doesn't work that way. I believe the return value of req.getReader() is
going to deliver text that looks like
myinput=%28assert+%28foo bar%29%28&mychoice=foo+bar...
The raw data that comes from the form being submitted. Furthermore,
it's not going to stay open - as soon as the request is processed, the
stream may be closed, and Jess might throw an exception when it notices.
Anyhow, don't write rules with readlines. Interpret the form inputs in
Java code, then assert the results into Jess, and call Rete.run() as
appropriate. The browser is going to drive the interaction.
I think Message UK wrote:
>
> Hi all. I'm having trouble with input to my servlet. What I am trying to do
> is take the posted info from teh browser and redirect it through jess's
> standard input.
>
> I can successfully output the HTML from the RHS of my 1st rule, by
> redirecting the output in MyMain as follows:
>
>
> m_rete.addOutputRouter("t", res.getWriter());
>
> and i have *attempted* to redirect the input to the servlet as follows:
>
> m_rete.addInputRouter("t", req.getReader(), true);
>
>
> but when I input my name, and press the submit button, I get an error:
>
> >Jess reported an error in routine Tokenizer.nextChar while executing
> > >(readline)
> >while executing (bind ?name (readline)) while executing defrule startup
> > >while executing (run).
> >Message: Error on input stream.
> >Program text: ( run ) at line 49.
> >Nested exception is:
> >java.net.SocketException: Connection reset by peer: JVM_recv in socket
> >input >stream read
>
> etc., etc.
>
>
> I have a .clp file as follows:
>
> ***********************************************************
> ;//template for each user
> (deftemplate user
> (slot name)
>
> )
>
> (defrule startup
> =>
> (printout t "<HTML><HEAD><TITLE>HIV Helper Page 1</TITLE>"
> "<BODY>"
> "<P>Welcome to HIV Helper!!!<BR>"
> "To enable you to use the Helper I need to ask you for<BR>"
> "some personal details...<BR>"
> "<P><FORM METHOD=GET ACTION=\"../servlet/Proto_separate\">Please enter your
> name:"
> "<INPUT TYPE=TEXT NAME=\"who\">"
> "<P><INPUT TYPE=SUBMIT></FORM>"
> "</BODY></HTML>" )
>
> (bind ?name (readline))
>
> )
>
>
> (defrule print_name
> ?u <- (user(name ?name))
> =>
> (printout t "<HTML><HEAD><TITLE>HIV Helper Page 2</TITLE>"
> "<BODY>"
> "<P>Hello there<BR>" + ?name
> "</BODY></HTML>" ))
>
> (reset)
> (run)
>
> ***********************************************************
>
> And I have a servlet which calls an amended version of jess.Main. Here's the
> servlet code:
>
>
> public class Proto_separate extends HttpServlet {
>
> // invoked by the browser doing a GET
>
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException
> {
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
> //start command
> String name = req.getParameter("name");
>
> String s = "testing.clp";
>
>
> if ("start".equals(name))
> {
>
> MyMain m = new MyMain();
> m.initialize(s, new Rete(), req, res);
> m.execute(true);
> }
>
> }
>
>
> Am I incorrectly redirecting the input? If so, how do I go about doing so
> correctly? Will JESS sit "running" waiting for the input as it does with the
> command line version, and the servlet automtically pass the input to JESS?
>
> Many thanks in advance for any help.
> Debbie Lampon
>
>
>
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------