Click here to Skip to main content
13,042,630 members (78,412 online)
Rate this:
Please Sign up or sign in to vote.
See more:

package scon;
import java.awt.List;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import javax.servlet.*;
import javax.servlet.http.*;
public class show {
	 * @param args
	public static final String MY_FOAF_FILE = "//home/ubuntu/indoor.rdf";
	public static HttpServletResponse response;
    public static HttpServletRequest request;
	public static void main(String[] args) {
		Model model = ModelFactory.createDefaultModel();
	       FileManager.get().readModel(model,MY_FOAF_FILE); File(MY_FOAF_FILE).toURI().toString());
	       String queryString =  "SELECT ?predicate ?object   WHERE {?subject ?predicate ?object .}";  
	       com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
        QueryExecution qe = QueryExecutionFactory.create(query, model);
        com.hp.hpl.jena.query.ResultSet results = qe.execSelect();
        ResultSetFormatter.out(System.out, results);
        ArrayList<rowobject> resultss = new ArrayList<rowobject>();
                while ( results.hasNext()) {
                    RowObject result = new RowObject();
                    QuerySolution binding = results.nextSolution();
                    // ...
                request.setAttribute("resultss", resultss); // Will be available as ${results} in JSP
                try {
					request.getRequestDispatcher("/wow.jsp").forward(request, response);
				} catch (ServletException e) {
					// TODO Auto-generated catch block
				} catch (IOException e) {
					// TODO Auto-generated catch block


PROBLEM: in unuderlined lines showing error , Exception in thread "main" java.lang.NullPointerException at, please help
Posted 28-Mar-13 17:58pm
Updated 29-Mar-13 4:36am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are a number of typos in your code, maybe some omitted code as well. Ignoring these, it seems that you have defined but not created either response nor request, so you will get NullPointerException when you attempt to use either of them.

Does your class have a constructor or a static initializer somewhere? The values in question are static, so probably shouldn't be initialized in the constructor without checking to see if they exist.

Try this:

public static HttpServletResponse response = new HttpServletResponse();
public static HttpServletRequest request = new HttpServletRequest();

It is not clear to me why these are static. I wouldn't code them that way...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100