I think Message UK wrote:
> 
> Howdy folks.
> 
> I'm having trouble with my servlet again...
> note, my jess folder is located within the servlet directory (it 
> wouldn't work for me otherwise):
> 
> c:\jdk1.2.2\jsdk2.1\examples\Web-inf\servlets\jess
> 

Sure; 'servlets' is usually the only user directory on a servlet's
CLASSPATH by default.

> but the source jess file (proto.clp) would only open when I placed it in the 
> server root directory:
> 
> c:\jdk1.2.2\jsdk2.1

This is the working directory the web server, and hence the servlet, gets.

> 
> and I moved the scriptlib.clp file there also, otherwise I got "can't open 
> file error" in the Dos window.

This is actually a problem in older Jess5 alpha versions. If you were
to upgrade to the newest one (5.0a5 or 5.0a6) you'd find that you
could leave this file where it was and it would be read fine.

> 
> With all that "fixed", I run my servlet Proto.class, from an html
> page ... and that submits ok, but then the response I get is:
> 
> Internal Servlet Error:
> 
> java.lang.NullPointerException
>       at Proto.doGet(Proto.java:35)
...

> 
> My source code (adapted jess.Main) is as follows:
> 
...
> 
>               String name = req.getParameter("name");
... [Editor: the line below is line 35]
> 
>         if (name.equals("start"))

Note that req.getParameter can return null, and you haven't checked
for null; then you call equals() on the null value. Here's a Java tip:
always write "start".equals(name) instead of the other way around -
this will never throw an exception.

Note also that getParatemer is deprecated; the replacement is
getParameters(), which returns an array of parameters with that
name. Now you have to call getParameters(), check that it didn't
return null, check the length >=1, then take the zero-th element of
the array, and, to be safe, check that for null too.

As to why it's coming up null: looking at your HTML, it looks like
there should be a parameter by that name - unless you're neglecting to
type something into the input field! But get the Java code strightened
out, then investiagate where the null is coming from.


---------------------------------------------------------
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]
---------------------------------------------------------------------

Reply via email to