File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes New Window from a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "New Window from a Servlet" Watch "New Window from a Servlet" New topic
Author

New Window from a Servlet

Rohit Shinde
Greenhorn

Joined: Dec 01, 2010
Posts: 2
Hello All,

How can I make a servlet open a new browser window (or a pop-up window) at the client end with an html form in it?

Thanks a lot in advance,
RookieServletPrgmer

I have posted this doubt on multiple forums !!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

You can't.

The opening of the new window must happen on the client and the request made to the new window. This can be done with window.open(), or with a target attribute on a link or form.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Crossposted: http://www.java-forums.org/java-servlet/35525-new-window-servlet.html and http://www.javaprogrammingforums.com/java-servlet/6281-new-window-servlet.html
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

Please let us know when you've cross-posted to other sites. Thanks.
Rohit Shinde
Greenhorn

Joined: Dec 01, 2010
Posts: 2
I certainly will Sir..... I am new to these forums and am not familiar with the etiquette's.. I am extremely sorry.

But I would like Thank you so much for your help & advice.

Best Regards !!
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

What you have to do is , from your servlet , you need get access to PrintWriter ,

PrintWriter out = response.getWriter();

Now you should explicitly construct an HTML Page this way :


and depending upon your requirement call this function , which will open this new page for you if exists

Save India From Corruption - Anna Hazare.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: New Window from a Servlet
 
Similar Threads
A new Session in another browser window?
how does the servlet knows that the client has closed the browser
Can I use RequestDispatcher to open a new browser window
Opening in a new window
Making newWindow Scroll