Hot questions for Using Neo4j in servlets

Question:

I want to access the neo4j database. I tried the following:

    ClientResource resource = new ClientResource("http://localhost:7474/db/data/cypher");
    ChallengeResponse ch = new ChallengeResponse(ChallengeScheme.HTTP_BASIC);
    ch.setRawValue("bmVvNGo6bmVvNGo=");
    resource.setChallengeResponse(ch);
    Representation re = resource.post(query);

however, I get an error:

    Unauthorized (401) - Unauthorized

What am I doing wrong in the authentication?


Answer:

You are using neo4j/neo4j please change the password in the server first and then use that.

Question:

I am working on an webapplication and i have a neo4j database connected to it. I am using a iterator to find all the nodes like this:

 Iterator<Node> list_brands = result.columnAs("n");
        while (list_brands.hasNext()) {
            Node brand = list_brands.next();
            out.println(brand.getProperty("Titel", "null"));

        }

So this code gives me all the nodes with the property "Titel" I want each name on a new line.

I've tried like everything but nothing worked like:

/n, /r/n, System.getProperty(line.separator);

I hope you can help me with this.


Answer:

Expanding on the comments, you need to use HTML linebreaks (<br/>) to get them in the browser.

out.println(brand.getProperty("Titel<br/>")); won't work, since I assume there's no property with that name.

Instead you need to write <br/> to your JSP, e.g. by calling

out.print(brand.getProperty("Titel")); //no println() here, because newline is not needed
out.print("<br/>"); //write the html tag to the JSP's output stream

Btw, I'd probably check whether that property exists before trying to print it.