Open JSP in new browsertab from serverside code

Is it possible to open a resource into a new browser Tab (like target="_newtab" for command buttons) from server side jsf code?

The following Code opens the resource in the same tab:


I'm using primefaces. I think there is a possibility with javascript and icefaces.


You cannot control that in the server side. You need to control that in the client side. For example, the command button invoking the bean's action should have a target="_blank" on its parent <h:form>.

<h:form target="_blank">
    <h:commandButton value="Submit" action="#{bean.submit}" />

Or if you aren't doing any postprocessing stuff in the action method, just replace that button altogether by a plain link.

<a href="resource.jsp" target="_blank">link</a>

The best solution that I found was:

RequestContext context = RequestContext.getCurrentInstance();
context.execute("'resource.jsp', '_newtab')");

This worked for me on Icefaces:

JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(), ", '_newtab');");

where dir is the direction of the new tab.

Need Your Help

Allow only numbers into a input text box

html input textbox numbers

I have a number input text box and I want to allow the user to edit but do not want to allow the user to enter any other text except numbers. I want them only to be able to use the arrows on the nu...

Log4net with SyslogAppender, 1kb message limit

log4net syslog

Has anyone found a way to get around this? Or a better technique to conglomerate logging from multiple web servers reliably?