Access file in WebContent folder from a servlet

前端 未结 3 745
生来不讨喜
生来不讨喜 2021-02-06 04:56

I\'m trying to generate a PDF document using FOP. The pdf generation code is kept in a servlet and the xsl is in a specific folder in the WebContent folder.

How can I a

3条回答
  •  不思量自难忘°
    2021-02-06 05:53

    I used the following method to read the file under web content

    BufferedReader reader = new BufferedReader(new InputStreamReader(request.getSession().getServletContext().getResourceAsStream("/json/sampleJson.json")));
    

    Now all the file content is available in the reader object.

提交回复
热议问题