0

I'm trying to write a Servlet in Eclipse and I've written the following service method. I'm simply trying to receive a string in JSON format from the request. Then I'm using the JSON simple library to process the request, after having gotten the output, sent in back via the response object.

When I try to call anything from the JSON library, I'm getting a class not found exception. I have added the jar for the library in the build path of Eclipse.

I'm using Tomcat 7 for the Server. Is there any other folder in the Tomcat directory where I need to add the jar file of the JSON library in order to use it in a Tomcat servlet? I haven't found any of the other questions that are similar to this one on here, useful to help me solve this problem.

public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String json_in = request.getParameter("text");
    if (json_in != null){
        Query query = handleQuery(parse(json_in));
        PrintWriter out = response.getWriter();
        if (query.input_format.equals("interval")){
            String message = "No interval was given in query";
            out.write(message.toCharArray());
        }
        else if (query.input_format.equals("chromosome")){
            String message = "No chromosome was given";
            out.write(message.toCharArray());
        }
        else{
            String message = "No source was given";
            out.write(message.toCharArray());
        }

    }
}
Bryan
  • 747
  • 1
  • 7
  • 19
eager2learn
  • 1,447
  • 4
  • 24
  • 47

0 Answers0