0

Building a web app with Javalin. How do I display a PDF from my staticfiles folder in the app.post function?

I can't use .getResourceAsStream because it has images, and the function couldn't parse it. I can serve html files using ctx.html but can't find similar for PDF. I can find it manually by typing the file name into the address bar but want to serve it automatically.

vvv
  • 1
  • Your PDF is in the static files location, so you don't need any specific logic in a Javalin route. You can just use the static URL directly (no need for `getResourceAsStream`) . For example: `http://your-webapp-root/sample.pdf`. Or, within the app itself, just `/sample.pdf`. It's no different from a static CSS file, JS file, etc. – andrewJames Feb 08 '23 at 13:38
  • (Just to check: You have configured the Javalin static file location, right?) – andrewJames Feb 08 '23 at 13:40

0 Answers0