Topic
No replies
SalimReggae
SalimReggae
66 Posts
ACCEPTED ANSWER

Pinned topic Opening the pdf in a new window

‏2012-04-10T14:07:37Z |
Hi,

We are developing a web portal on websphere portal 6.1 with IBM RAD 8.0.3 and Faces 1.1.
In the subject portal, we try to implement a pdf creator. For that purpose we developed a pdf creator servlet based on itext library. The servlet runs properly, if we try to access it through a command

button (because we have to execute some java code before creatng the pdf) by using the following phrase inside the command button's action method;

getFacesContext().getExternalContext().redirect("/.Portlet21/servlet/com.servlet.CreatePdfServlet");

Here, the problem is that the created pdf is opened in the same browser window,but we want to open the pdf in a new browser window. Therefore, we tried to access the Servlet by using commandlink (with

target="_blank"), but it doesn't create a new window. In order to get round this problem, we created a blankpage with the folowing code in its pageload:

getFacesContext().getExternalContext().dispatch("/.Portlet21/servlet/com.servlet.CreatePdfServlet");

But this again didn't help.The problem here is that the portlet tries to open the servlet inide the portlet's field not the browser window. (java.lang.IllegalStateException: getWriter can't be used after

getOutputStream was invoked)

and using the redirect() instead of dispatch

getFacesContext().getExternalContext().redirect("/.Portlet21/servlet/com.servlet.CreatePdfServlet");

didn't work either.

Do you have any idea about how to access the servlet and opwn the pdf in a new browser window?

Best Regards,
O.