I have:
a JSP-file called index.jsp
which contains the following code:
<%
JSONVerschillendeTalen jsonVerschillendeTalen = JSONVerschillendeTalen.getInstance();
JSONObject algemeenJSON = null;
JSONObject indexJSON = null;
try {
indexJSON = jsonVerschillendeTalen.getJSONObject(request, "Index.txt");
algemeenJSON = jsonVerschillendeTalen.getJSONObject(request, "Algemeen.txt");
} catch (ParseException e) {
e.printStackTrace();
}
%>
And a class called JSONVerschillendeTalen
which contains the following code:
public class JSONVerschillendeTalen {
private static JSONVerschillendeTalen jsonVerschillendeTalen = new JSONVerschillendeTalen();
private JSONParser jsonParser = new JSONParser();
public static JSONVerschillendeTalen getInstance() {
return jsonVerschillendeTalen;
}
public JSONObject getJSONObject(HttpServletRequest req, String bestandsnaam) throws IOException, ParseException {
return (JSONObject) jsonParser.parse(new FileReader(getClass().getClassLoader()
.getResource("NL/" + bestandsnaam).getPath().replaceAll("%20", " ")));
}
private JSONVerschillendeTalen() {
}
}
Whenever I run the code in the index.jsp
file in a normal class (for testing), it works. When I run the same code in the jsp file, it doesn't. Does anybody know why?