I am creating a dynamic web application in Java using Eclipse. My web application basically creates PDF files by getting information from IOS app.
After creating PDFs, I want to show it inside the IOS app. I saved the generated PDF files dynamically into the
The Tomcat server isn't going to display static resources (*.jpg, *.png, *.pdf etc) automatically unless it's been instructed to do so. In order to have Tomcat retrieve those resources, add the following to your web.xml
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.pdf</url-pattern> </servlet-mapping>
Note that you're using a
default servlet and not your custom servlet that handles dynamic content.
This example assumes that you store your PDFs to the file system (in a folder accessible to your web app). Just because they're created on-the-fly (dynamically) doesn't matter as long as you return an URL to the generated file.
UPDATE: Your servlet should return the URL to your PDF file, e.g
Now, when you click that link (either in the browser or your iOS app), the PDF will be downloaded to your client.