This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Open JSP page in new tab(browser) from request from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Open JSP page in new tab(browser) from request from servlet" Watch "Open JSP page in new tab(browser) from request from servlet" New topic
Author

Open JSP page in new tab(browser) from request from servlet

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

Hi is it possible to open jsp page in new tab(browser) from a servlet. Like if i have a jsp first.jsp it has a link in grid(so many) when user clicks on that link it is going to a servlet say(RequestedLinkServlet)
my code in servlet is

please help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

On the link (or form) to the servlet, use the attribute target="_blank". This will cause the response to appear in a new window or tab as specified by the browser settings.

A few points before you ask:
  • No, you can't just do this from the servlet. It must be specified in the HTML that invokes the servlet.
  • No, you cannot override the browser's setting. If the browser is set to open new pages in a new window, you cannot cause it to open a new tab, and vice versa.


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Rob Spoor
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19651
        
      18

    Opening new windows / tabs is a client action, and can be done using the target attribute Bear mentioned or with JavaScript. The only way to trigger it from the server is to open a page that will automatically open a new window / tab using JavaScript.


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Open JSP page in new tab(browser) from request from servlet
     
    Similar Threads
    How to get data back on result page from struts
    Open an XML file in a popup window
    display a arraylist value in JSP using JSTL
    Using servlets with java beans
    How to store value in hidden field with struts 2.0?