Search code examples
javaservletsrequestdispatcher

request.getRequestDispatcher().forward(request, response) in a new page


like the title say I would like to know if it's possible (and if it's possible, also how) to open a jsp page In a new TAB of the browser;

Now I'm using this istruction but the page will appear in the same tab of the browser.

request.getRequestDispatcher("page.jsp").forward(request, response);

the call to the servlet, in the client side is this:

<img id="imgModAbb" src="imm/historyAbb.png"
                        title="Vedi storico modifiche" 
                        onclick="window.location.href='/Spinning/InfoStoricoAbbonamento?id=<%=a.getIdAbbonamento()%>'">

SOLUTION

I modified the calling in the client-side:

<a href="ServletAddress" target="_blank">
 <img id="imgModAbb" src="imm/historyAbb.png" title="Vedi storico modifiche">
</a>

Solution

  • That cannot be controlled in the server side. You need to control that in the client side. For example, you can use target="_blank" on <form>:

    <form name="input" action="${toServlet}" method="POST" target="_blank">
    ...
    </form>