Buggy code:
public class SearchServlet extends HttpServlet { private static final long serialVersionUID = 1L ; private static final String db = "http:////localhost:3030//Thesis//query" ; private final OntModel m = ModelFactory . createOntologyModel ( OWL_DL_MEM , null ) ; private QueryInfo qi = new QueryInfo ( ) ; protected void doPost ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { String keyword ; keyword = request . getParameter ( "keyword" ) ; <START_BUG> String queryString = "prefix<seq2seq4repair_space>j.0:<seq2seq4repair_space><http:////mooclink.asu.edu//coursera#>\n" + ( ( ( ( "PREFIX<seq2seq4repair_space>rdf:<seq2seq4repair_space><http:////www.w3.org//1999//02//22-rdf-syntax-ns#>\n" + "PREFIX<seq2seq4repair_space>schema:<seq2seq4repair_space><http:////schema.org//>\n" ) + "SELECT<seq2seq4repair_space>?Course_ID<seq2seq4repair_space>?Course_Format<seq2seq4repair_space>?Course_name<seq2seq4repair_space>WHERE<seq2seq4repair_space>{\n" ) + "<seq2seq4repair_space>?course<seq2seq4repair_space>j.0:Course_ID<seq2seq4repair_space>?Course_ID<seq2seq4repair_space>;<seq2seq4repair_space>j.0:Course_Format<seq2seq4repair_space>?Course_Format<seq2seq4repair_space>;<seq2seq4repair_space>schema:name<seq2seq4repair_space>?Course_name<seq2seq4repair_space>.\n" ) + "}" ) ; <END_BUG> Query query = QueryFactory . create ( queryString ) ; QueryExecution qexec = QueryExecutionFactory . sparqlService ( SearchServlet . db , query ) ; ArrayList < Object > jsonObj = new ArrayList < Object > ( ) ; try { ResultSet responseResultSet = qexec . execSelect ( ) ; while ( responseResultSet . hasNext ( ) ) { HashMap < String , String > j = new HashMap < String , String > ( ) ; Gson gson = new Gson ( ) ; QuerySolution soln = responseResultSet . nextSolution ( ) ; RDFNode name = soln . get ( "?Course_ID" ) ; RDFNode duration = soln . get ( "?Course_Format" ) ; RDFNode difficulty = soln . get ( "?Course_name" ) ; j . put ( "Course_ID" , name . toString ( ) ) ; j . put ( "Course_Format" , duration . toString ( ) ) ; j . put ( "Course_name" , difficulty . toString ( ) ) ; jsonObj . add ( j ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } String json1 = new Gson ( ) . toJson ( jsonObj ) ; response . setContentType ( "application//json" ) ; response . setCharacterEncoding ( "UTF-8" ) ; response . getWriter ( ) . print ( json1 ) ; } public String removeLastChar ( String s ) { } }

Fix:
String queryString = ( ( ( "prefix<seq2seq4repair_space>j.0:<seq2seq4repair_space><http:////mooclink.asu.edu//coursera#>\n" + ( ( ( ( "PREFIX<seq2seq4repair_space>rdf:<seq2seq4repair_space><http:////www.w3.org//1999//02//22-rdf-syntax-ns#>\n" + "PREFIX<seq2seq4repair_space>schema:<seq2seq4repair_space><http:////schema.org//>\n" ) + "SELECT<seq2seq4repair_space>?Course_ID<seq2seq4repair_space>?Course_Format<seq2seq4repair_space>?Course_name<seq2seq4repair_space>WHERE<seq2seq4repair_space>{\n" ) + "<seq2seq4repair_space>?course<seq2seq4repair_space>j.0:Course_ID<seq2seq4repair_space>?Course_ID<seq2seq4repair_space>;<seq2seq4repair_space>j.0:Course_Format<seq2seq4repair_space>?Course_Format<seq2seq4repair_space>;<seq2seq4repair_space>schema:name<seq2seq4repair_space>?Course_name<seq2seq4repair_space>.\n" ) + "FILTER<seq2seq4repair_space>(regex(?Course_name,<seq2seq4repair_space>\"" ) ) + keyword ) + "\",<seq2seq4repair_space>\"i\")).\n" ) + "}" ;