The Requirement is to open a PDF file from a jsp without any redirection in single click using Ajax POST.
JSP -> AJAX Post Call -> Server Code returning Response to Ajax -> Print the PDF with the returned data
Ajax Code:
- Code: Select all
$.ajax({
type: "POST",
url: "/PrintDocument/PrintServlet?type=pdf",
data: 'htmlContent='+ escape(someDataToServlet),
success: function(data){
alert(data);
// To-do block to oepn the PDF
},
error:function (data){
}
});
Servlet Code:
FOSettings foSettings = Docx4J.createFOSettings(); ...