I tried the following code to see if I can get the output
<%
Rete r = new Rete();
StringWriter sw = new StringWriter();
r.addOutputRouter("t", sw);
r.executeCommand("(batch C:/temp/kbsproj.clp)");
r.executeCommand("(reset)");
r.executeCommand("(run)");
// r.executeCommand("(printout t 12345 crlf)");
String myString = sw.toString();
%>
<%= myString %>
With just the (printout) command, I was able to print the values on the
webpage. But after adding the codes to execute a clips file, the
following error came up.
org.apache.jasper.JasperException: Error on input stream
I'm stucked.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Friday, October 17, 2003 11:33 PM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Jess routers
I think Anthony Wong wrote:
> Hi. I'm trying to get the 'printout' from Jess statement and put them
> into JSP. Does anyone have any example on that? Need some help.
>
>
>
> Supposedly, I have this command in the clips file - (printout t "Hello
> World' crlf) on the RHS of a rule. Would it be possible to get this
> output "Hello World" on the web page?
>
>
>
> I had tried the following. The example I had were pretty similar to
the
> TekMart from the book Jess in Action. I have the same BaseServlet to
> initialize the Rete object and to make a batch call to the clips file.
>
Well, what you're doing here looks OK except that if this code is
cut-and-pastes, then you're not issuing any printouts between defining
the router and forwarding the request, so the string will be
empty. You have to define the router -before- printing to it, just
like you have to open a file -before- writing data into it.
>
>
> Then I have another servlet, say TestRequest
>
>
>
> checkInitialized();
>
>
>
> ServletContext servletContext = getServletContext();
>
> Rete engine = (Rete) servletContext.getAttribute("engine");
>
>
>
> StringWriter sw = new StringWriter();
>
> engine.addOutputRouter("t", sw);
>
>
>
> String myString = sw.toString();
>
> request.setAttribute("testString", myString);
>
>
>
> dispatch(request, response, "/test.jsp");
>
>
>
> on test.jsp, I have
>
>
>
> <%= request.getAttribute("testString").toString() %>
>
>
>
> Does any of the above make sense?
>
>
>
> Thanks.
>
>
>
> Anthony
>
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
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]
--------------------------------------------------------------------
--------------------------------------------------------------------
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]
--------------------------------------------------------------------