Basically we have a JSF app that dynamically generates a link to a servlet, which serves up the PDF file. I need to pass the path of the PDF to the servlet. I have no idea of how to pass data to a servlet.
In the View we have:
<d:protocolSection value="#{detailBacker.studyData}" id="protocol" />
In the controller we have
public string getFile() {
.......
// some variable here that holds the folder and file name
result += "<a href=\"/catalog/catalog/WelcomeServlet\" target=\"_blank\">" + name + "</a>
.......
}
I basically need to send the variable that holds the folder and file name to the WelcomeServlet somehow so that the WelcomeServlet can use it.
Pass it as a request parameter or pathinfo the usual Servlet way.
Here’s an example assuming pathinfo is preferred and
#{bean.pdfpath}returns something likefilename.pdf:In the servlet mapped on an URL pattern of
/pdf/*you can get it as follows indoGet()method:As a completely different alternative, you can also just let JSF write the PDF to the response in a commandlink/commandbutton action method.