• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirecting servlet response between windows

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 browser windows open (say A and B). On one of the windows (say on A), when I click on the submit button, it calls a servlet (which does some stuff). When the servlet finishes, I want to send the resonse to the other browser window (window B). I am using response.sendRedirect(), but this is sending it back to the original window (A), as expected. Is there a way to send the response to the other window?
Thx.
Ulvi.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is - a response is always sent to the browser a request came from.
Your browser B might be running some sort of JavaScript loop checking for the availability of the newly computed page.
It would be easiest if window B was opened from window A so they would share the same sessionID cookie.
Bill
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As William pointed out, once the request is sent to a specific window, that is where the response will be sent.
If you want the response to appear in the 2nd window, you will need to submit the request to it and not to the first window.
If the request is triggered via a form submission, or the result of clicking a link, you can control which window the request is submitted to with the target attribute in the form or anchor tag.
If you need more control than that, you can create the window via window.open() and then control any Javascript in the page loaded into that window, or even submit the request directly to that window.
hth,
bear
[ July 22, 2003: Message edited by: Bear Bibeault ]
[ July 22, 2003: Message edited by: Bear Bibeault ]
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, to put it another way, HTTP can't send unsolicited information, only info in response to a request.
And the response always goes back to the same place it was requested from.
 
reply
    Bookmark Topic Watch Topic
  • New Topic