Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64826
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  •  
    Rob Spoor
    Sheriff
    Pie
    Posts: 20527
    54
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic