This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Send response to a Frame or Parent of a Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Send response to a Frame or Parent of a Frame" Watch "Send response to a Frame or Parent of a Frame" New topic
Author

Send response to a Frame or Parent of a Frame

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Based on the result of some business logic, my servlet needs to decide (on the fly) to send the response back to either the frame or to the parent of the frame.
Is this possible?
Thanks!


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

It is not. The response will be sent back to the window or frame that originated the request. You need to decide which frame will get the request prior to submission.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
Originally posted by Bear Bibeault:
It is not. The response will be sent back to the window or frame that originated the request. You need to decide which frame will get the request prior to submission.

To expand a bit on Bear's reply,
The response will be sent back to the originating window or frame, unless the target attribute is set to point to a different window or frame, but as Bear says, this does need to be known at request time.
If the logic that determines the target is based on request paramters, you can set the target via client side Javascript. If this needs to be determined on the server side, then you're out of luck.


Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
Thanks for the responses.
I do need to determine where the page should go at server side. How about this plan:
Assume my servlet is originated from frame1. If I want the page go back to frame1 I send this page back:

If I want the page go back to the parent of frame1 I send this back:
 
jQuery in Action, 2nd edition
 
subject: Send response to a Frame or Parent of a Frame
 
Similar Threads
handling frames
floating JToolBar doesn't close
i want no reponse from servlet
conditionally targetting the client frame based on Server(servlet) program
Sending two files after successful login