user4815418
user4815418

Reputation:

How to access json file stored under web-app inside servlet & jsp?

I have my json file that I am going to place under web-app folder. This file is not generated on the fly but created manually. Hence want to store under web-app. I need to render the page in jsp/servlet using this json file. How to get access to json file in this scenario?

Upvotes: 1

Views: 772

Answers (1)

dr-
dr-

Reputation: 113

Create a servlet and serve the file from there to the clients. You can load it with

servletContext.getResourceAsStream("/WEB-INF/file.json");

and write it directly to your OutputStream.

Upvotes: 1

Related Questions