This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Frames and Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Frames and Servlets" Watch "Frames and Servlets" New topic
Author

Frames and Servlets

Tejpal Singh
Greenhorn

Joined: Aug 08, 2003
Posts: 26
Hi,
I have a html called defaultFrame.htm that generates three frames calling topnav.htm(topframe) and leftnav.htm(leftframe) and a servlet(mainframe).
I want that whenever an exception occurs in servlet the response is an error page but in one frame only, the topnav and leftnav frames should not be visible or generated.
My question is:
1. Is there a way to specify target in servlets? if so then how?
2. Is there any other way of achieving this when an exception occurs in servlet.
Thanks in advance.


"When work, commitment and pleasure all become one and you reach that deep well where passion lives, nothing is impossible."
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
1. The "target" can only be determined on the browser side with your HTML.
2. Right off-hand, I can't see how you would accomplish this with your present frame definition since each frame is filled by a separate request.
If you create the frameset with a servlet, then you could control whether or not the navigation frames are displayed.
Bill
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

Your error page can, on the client-side using a Javascript onload handler, check to see if it is being displayed in the top-most frame or not. And if not, reload itself there. The tricky part is propagating the error information to the reloaded page (hint: hidden fields).
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
maneesh subherwal
Ranch Hand

Joined: Aug 26, 2002
Posts: 42
I achieved something similar using a modal dialog to call my servlet and sending the window object to the modal dialog.
OnLoad of the modal dialog, the window object can be accessed using window.dialogArguments and each frame can be updated using DIV objects and/or innerHTML.
Finally, you can close the modal dialog. The dialog box flickers on the screen for a millisecond but it surely works.
I believe you could do the same using a hidden frame as well instead of a modal dialog. As Bear correctly suggested, Hidden fields would help as well.
Please refer to the msdn site and search on showmodalDialog. This is slightly tricky but it works.
I hope this helps...
Thanks,
Maneesh


Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
Tejpal Singh
Greenhorn

Joined: Aug 08, 2003
Posts: 26
Thanks Manish, Bear and William for your precious help...
I used your suggestions and a little bit trial and error and found a solution to my problem...
I am posting sample code for anyone who may have a similar problem...

By writing the above html to the browser from my servlet i was able to kill the frames and display the login.htm file.
PS: The "on load" attribute in body tag should be without space. The javaranch didnt allow to submit me the reply with without space.
Cheers!!
[ September 11, 2003: Message edited by: Tejpal Singh ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Thanks Tejpal for sharing the code.


Groovy
Tejpal Singh
Greenhorn

Joined: Aug 08, 2003
Posts: 26
Originally posted by Pradeep Bhat:
Thanks Tejpal for sharing the code.

It's my pleasure Pradeep!!
Thats how we grow aint it!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frames and Servlets