Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:13:57+00:00 2026-06-02T20:13:57+00:00

I have just begun with AJAX. I’m not sure about many things, though I

  • 0

I have just begun with AJAX. I’m not sure about many things, though I picked up a few tutorials on the internet and started working. I apologize for pasting a lot of code, but I don’t have much of an idea as to where am I going wrong. Thank you for your help though! 🙂

Here is my JSP(only the javascript part) and servlet code :(followed by the exception and followed by equivalent the Java code that I would use for a normal Java application) :

JSP:

//--Function to get the xmlhttp object
function getHttpObject(){
    var xmlhttp = null;
    if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
    else if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    else {alert("Your browser does not support XMLHTTP!");}
    return xmlhttp;
}   

function populateReply(str){
    xmlhttp = getHttpObject();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState==4){
            ajxfrm.chatresponse.value=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET","NewServlet?chatinput="+str,true);
    xmlhttp.send(null);
}

Servlet :

public class NewServlet extends HttpServlet implements Servlet {

NetworkAimlFacade aiml = null;
int status = 0;
String botName;
String param[];
GraphBuilder builder;


public NewServlet() throws Exception{
    super();

    aiml = new NetworkAimlFacade(param);
    builder = aiml.getNetworkGraphBuilder();
    builder.addDirectoryUnlessAlreadyAdded
    (
        "C:\\Program Files\\RebeccaAIML\\aiml\\annotated_alice"
    );
    builder.createGraph();
    botName = builder.getBotPredicate("name");

}

private String handleRequest(String param){
    return null;
}

public void destroy()
{
    try{
    aiml.destroy();
    }catch(Exception e){
        e.printStackTrace();
    }
}

protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{

    res.setContentType("text/xml");
    res.setHeader("Cache-Control", "no-store, no-cache");
    String input = "";
    if(req.getParameter("chatinput") != null) 
        input = req.getParameter("chatinput");
    try{
        String response = builder.getResponse(input);
        if(response!=null)    res.getWriter().write(response);
            else res.getWriter().write("No");
    }catch(Exception e){
        e.printStackTrace();
    }

}

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

}}

Here’s the error that I get, instead of getting the response from the servlet:

Apache Tomcat/7.0.11 – Error report

HTTP Status 500 –

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

    javax.servlet.ServletException: Error instantiating servlet class NewServlet
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)  
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)   
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)   
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) 
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)  
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)    
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)    
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    java.lang.Thread.run(Thread.java:619)

root cause

java.lang.NullPointerException  Ice.PropertiesI.<init>(PropertiesI.java:250)
    Ice.Util.createProperties(Util.java:29)
    Ice.Util.initialize(Util.java:70)
    Ice.Util.initialize(Util.java:49)
    Ice.Util.initialize(Util.java:56)
    rebecca.NetworkGraphBuilderAIML.<init>(Unknown Source)    
    rebecca.NetworkAimlFacade.<init>(Unknown Source)  
    NewServlet.<init>(NewServlet.java:27)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    java.lang.Class.newInstance0(Class.java:355)
    java.lang.Class.newInstance(Class.java:308)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:619)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.

Apache Tomcat/7.0.11

Here’s the equivalent Java code, that I use in a normal Java application, and it works fine!

  public class Console {

  public static void main(String args[]) {
  NetworkAimlFacade aiml = null;
  int status = 0;
  try {
    aiml = new NetworkAimlFacade(args);
    GraphBuilder builder = 
        aiml.getNetworkGraphBuilder();
    builder.addDirectoryUnlessAlreadyAdded
    (
      "C:\\Program Files\\RebeccaAIML\\aiml\\annotated_alice"
    );
    builder.createGraph();
    String botName = 
        builder.getBotPredicate("name");
    String initialResponse = 
        builder.getResponse("connect");
    System.out.println(botName + " says: " + 
        initialResponse);
    while(true) {
      System.out.print("You say> ");
      BufferedReader br = 
        new BufferedReader(new 
            InputStreamReader(System.in));
      String input = br.readLine();
      if(input.equals("/exit")) {
        break;
      } else {

String response = 
            builder.getResponse(input);
        System.out.println("=====================");
        //Print out what Rebecca says.
        System.out.println(botName + " says: " + 
            response);
        }
    }
    aiml.destroy();
    } catch(NetworkException e) {
      e.printStackTrace();
      status = 1;
    } catch (Exception e) {
      e.printStackTrace();
      status = 1;
    }
    System.exit(status);
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:14:01+00:00Added an answer on June 2, 2026 at 8:14 pm

    Here’s an extract of relevance from your exception:

    javax.servlet.ServletException: Error instantiating servlet class NewServlet
      ...
    java.lang.NullPointerException 
      Ice.PropertiesI.<init>(PropertiesI.java:250)
      Ice.Util.createProperties(Util.java:29)
      Ice.Util.initialize(Util.java:70)
      Ice.Util.initialize(Util.java:49)
      Ice.Util.initialize(Util.java:56)
      rebecca.NetworkGraphBuilderAIML.<init>(Unknown Source)
      rebecca.NetworkAimlFacade.<init>(Unknown Source)
      NewServlet.<init>(NewServlet.java:27)
      ...
    

    In other words, when the container tried to do

    Servlet serlvet = new NewServlet();
    

    It failed, because something in the constructor of PropertiesI class, at line 250, expected some object to be not null and tried to access it directly without checking beforehand if it’s null or not. Check the source code of PropertiesI class at line 250 and fix it accordingly.

    This all has nothing to do with ajax or servlets. Learn how to interpret exceptions and stacktraces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading about the State pattern. I have only just begun, so of course
I've just begun learning Silverlight (though I have 3 years C# experience). I'm trying
I have just begun learning ember.js, I have followed some tutorials and created a
I have just begun to work with the jquery validate plugin but have not
I have just begun to look at tornado and asynchronous web servers. In many
I have just begun working on a project which uses Mercurial as a version
I have just begun working with the Android SDK and I am having problems
I have just begun to use Visual Studio Team System 2008 Database Edition. I'm
i have just begun working on android platform.I installed both eclipse and android sdk.Now
I have just begun reading into Java annotations. I need to print out all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.