Meaningless Drivel is fun!
The moose likes HTML, CSS and JavaScript and the fly likes opening a new window from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "opening a new window from servlet" Watch "opening a new window from servlet" New topic

opening a new window from servlet

Joseph Siao
Ranch Hand

Joined: Feb 26, 2004
Posts: 32
I have a jsp page that calls on a servlet. The servlet does something, like connect to a database, then get some data. after that, the servlet calls another jsp page.

my code for calling the new jsp page :

RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("next.jsp");

question : i want the next.jsp page to open on a new window, how do i do this?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Servlet code can do absolutely no client browser manipulation. Why? Because its serverside. You need clientside code to do this, so your only route is JavaScript.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

I'll move this to the HTML and Javascript forum.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
basically you need to have the servlet write the javascript statement to open the new window...

One problem, people with pop up blockers are going to block this window from opening.

I agree. Here's the link:
subject: opening a new window from servlet
It's not a secret anymore!