Hello, I'm developing a web application using Servlets and JSPs. I do not have much experience yet.
My page contains a button that downloads a BD file and a <object>
html to display a PDF that is in the BD.
The button works normally, but the PDF does not appear. It is not appearing because I pass as a parameter the id
with request.getParameter("id")
, but the problem is that it does not even make a request for this my Servlet.
For example, my select looks like this:
SELECT pdf from pdf WHERE id = ?
When I give request.getParameter("id")
and I pass id
as a parameter in this query does not work, but if I change query by passing a parameter like:
SELECT pdf from pdf WHERE id = 1
Then the PDF loads on the page.
In short: I have a JSP, which contains just one button that request for a Servlet to download a DB file. It works perfectly and I have <object>
to display a PDF that is also stored in the DB, but it does not work as I explained.
What I think may be happening is that the button works because when I give submit
it requests the Servlet, but the PDF is already loaded on the screen when the page opens and I do not have much programming experience yet Java for the WEB, I can not make a request to the Servlet when the page loads.
Could anyone help me with this? Do I need some Javascript function or something similar to make the request and pass the parameter to my PDF Servlet?