aspose file tools*
The moose likes Servlets and the fly likes how to show response in new window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to show response in new window" Watch "how to show response in new window" New topic
Author

how to show response in new window

swapnel surade
Ranch Hand

Joined: Mar 05, 2009
Posts: 129
hi

I want to show the response in new browser window after clicking on the button or link.
Please tell me the way to achieve this functionality.

thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You will need to use JavaScript to do this, some thing like

should do it.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Noble Bhaskar Aswanapally
Greenhorn

Joined: Mar 05, 2007
Posts: 13

use target="_blank" HTML attribute

example:
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 605

I don't think that there is any server side code that could help you with this. You cannot open a new browser window for the response from the server.

You can however get the response in a new window at the client side. In case of links and forms it is a simple matter of adding target='_blank'. Just one points here,
1. target attribute is Deprecated - so its a bad practice to use it.

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Noble Bhaskar Aswanapally wrote:use target="_blank" HTML attribute

example:


Though this will work it is not the best way to do it - it is not valid HTML.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 605

Paul Sturrock wrote:


Though this will work it is not the best way to do it - it is not valid HTML.


Why not - its still an legal HTML attribute right (Deprecated does not mean illegal)? I agree it bad but so is window.open() - putting in JavaSciprt inside a anchor tag so that its valid XHTML seems equally bad.

I was trying to look for it but could not find the reason why the 'target' tag is depreciated - anyone has an idea?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The reason its not valid, rather than just deprecated, is its existance in an HTML page means the browser will swap to quirks mode.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Paul, the target attribute is alive and well according to the HTML 4 and 5 specifications. Where are you getting information regarding its invalidity?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its not part of HTML4.01 strict as far as I am aware.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Paul Sturrock wrote:Its not part of HTML4.01 strict as far as I am aware.


But contrasting to strict, we do have a loose.dtd. Right? So it can be valid there. Isnt it? Just a thought.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

It does not appear to be in that DTD, but the HTML 4 spec says nothing about that (not that it's the best-written spec I've had to deal with).

Luckily, I do not believe that HTML 5 has any of the loose vs strict nonsense. But it's early. They still have plenty of time to over-complicate things.

I use target everywhere with no difficulties.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Bear Bibeault wrote:
Luckily, I do not believe that HTML 5 has any of the loose vs strict nonsense. But it's early. They still have plenty of time to over-complicate things.

I use target everywhere with no difficulties.


Thats indeed a good & glad news
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to show response in new window