This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frames and Servlets

 
Tejpal Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
maneesh subherwal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tejpal Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tejpal for sharing the code.
 
Tejpal Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Thanks Tejpal for sharing the code.

It's my pleasure Pradeep!!
Thats how we grow aint it!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic