473,842 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching 404 and 500 in IFRAMEs?

Is there a way to catch HTTP 4xx and 5xx errors occuring in an IFRAME?
I want to replace the blue and white tomcat error pages, with a small
discrete text saying "The page currently not available".

The browser in question is Mozilla 1.3.1. But it would be nice if the
solution also worked in Opera 7.x, and IE 5.x and 6.x.

I know that setting an onError function on the IFRAME doesn't work,
both because [1]*says that it only works for JavaScript errors and not
for browser errors, and because I've tried it.

Searches on http://groups.google.com found me two threads about this
problem ([2], [3]), but no solutions that I could see.

One approach I could think about, is to set an onLoad function on the
frame, and check the load status code. Is the load status code
available on the frame? (One future problem here, is that I've heard
rumours about Opera having problems with onLoad)

Are there other possible solutions?

Thanx!
- Steinar
References:
[1] <URL:http://www.devguru.com/Technologies/...n_onerror.html >
[2] <URL:http://groups.google.com/groups?hl=n...8%26oe%3Dutf-8 >
[3] <URL:http://groups.google.com/groups?hl=n...8%26oe%3Dutf-8 >
Jul 20 '05 #1
8 28910
Steinar Bang wrote:
Is there a way to catch HTTP 4xx and 5xx errors occuring in an IFRAME?
I want to replace the blue and white tomcat error pages, with a small
discrete text saying "The page currently not available".

The browser in question is Mozilla 1.3.1. But it would be nice if the
solution also worked in Opera 7.x, and IE 5.x and 6.x.

[snip]

Don't do this with client-side code. Just configure your server
appropriately.

<URL:http://archives.real-time.com/pipermail/tomcat-devel/2000-January/003482.html>

--
Jim Dabell

Jul 20 '05 #2
Steinar Bang wrote:
Is there a way to catch HTTP 4xx and 5xx errors occuring in an IFRAME?
I want to replace the blue and white tomcat error pages, with a small
discrete text saying "The page currently not available".

The browser in question is Mozilla 1.3.1. But it would be nice if the
solution also worked in Opera 7.x, and IE 5.x and 6.x.

I know that setting an onError function on the IFRAME doesn't work,
both because [1] says that it only works for JavaScript errors and not
for browser errors, and because I've tried it.

Searches on http://groups.google.com found me two threads about this
problem ([2], [3]), but no solutions that I could see.

One approach I could think about, is to set an onLoad function on the
frame, and check the load status code. Is the load status code
available on the frame? (One future problem here, is that I've heard
rumours about Opera having problems with onLoad)

Are there other possible solutions?


As long as the iframe is in the same domain, you should be able to access its contents and if you identify a Tomcat error, either overwrite the content or make the iframe invisible by applying a different style. A better solution would be error
handling on the Tomcat server, though, or accessing Tomcat through an application that interprets the response from Tomcat and replaces it with a friendly message in case of failures.
--
Klaus Johannes Rusch
Kl********@atme dia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #3
>>>>> Jim Dabell <ji********@jim dabell.com>:
Don't do this with client-side code. Just configure your server
appropriately.


The application in question is a framework where custom pages can be
shown inside IFRAMEs, based on settings in the database.

I already do the server side stuff, with ErrorDocument directives
setting friendlier pages in apache's httpd.conf, and <error-page>
elements doing the same thing for tomcat in the webapp's web.xml file.

But I would have liked to let the JSP framwork on the to document
handle the case for errors happening on a separate server, displaying
in the IFRAMEs.

Looks like this isn't possible. Strange that the numerical HTTP
result code isn't available on the document objects...?
Jul 20 '05 #4
>>>>> Klaus Johannes Rusch <Kl********@atm edia.net>:
As long as the iframe is in the same domain, you should be able to
access its contents
It's not possible for JavaScript code in the top document to access
IFRAME content loaded from a different server, is that what you're
saying?
and if you identify a Tomcat error, either overwrite the content or
make the iframe invisible by applying a different style.
You mean parse the document to find out? I had been hoping to be able
to check the numerical HTTP result code for the document, but no such
luck.

Really strange that it isn't available. It seems such a simple thing
to implement, and simple thing to test against for error situations.
A better solution would be error handling on the Tomcat server,
though, or accessing Tomcat through an application that interprets
the response from Tomcat and replaces it with a friendly message in
case of failures.


Yup. I already do that for the server serving out the top document
(and the one most likely to serve out the other documents as well).

But like I said in another posting, I was hoping to have the JSP
framework in the top document being able to handle errors occuring on
a separate server, displaying inside one of the IFRAMEs.
- Steinar
Jul 20 '05 #5
In article <87************ @home.lan>, sb@dod.no enlightened us with...

But I would have liked to let the JSP framwork on the to document
handle the case for errors happening on a separate server, displaying
in the IFRAMEs.


Sure you can. Just check the document for existence before it is loaded
in the iframe with java's url class. After you verify it, then load it.
See comp.lang.java* groups.
-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #6
>>>>> kaeli <in************ ********@NOSPAM att.net>:
Sure you can. Just check the document for existence before it is
loaded in the iframe with java's url class. After you verify it,
then load it. See comp.lang.java* groups.


Is this something that requires a Java applet in the browser?
Jul 20 '05 #7
In article <87************ @home.lan>, sb@dod.no enlightened us with...
>> kaeli <in************ ********@NOSPAM att.net>:

Sure you can. Just check the document for existence before it is
loaded in the iframe with java's url class. After you verify it,
then load it. See comp.lang.java* groups.


Is this something that requires a Java applet in the browser?


No, you mentioned you use JSP. Use that.

Whatever opens the doc in the IFRAME must run on the server and check
the location before loading.
For example, if you load the iframe by a user clicking a link, set all
your links to one document (say, checkIt.jsp?
page=http://server.com/whatever.html) and send the url they want to load
as a parameter. Have checkIt.jsp check that location. If it exists,
change location to that page, if not display error. The same can be done
with button clicks, etc.

-------------------------------------------------
~kaeli~
Hey, if you got it flaunt it! If you don't, stare
at someone who does. Just don't lick the TV screen,
it leaves streaks.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #8
>>>>> kaeli <in************ ********@NOSPAM att.net>:
Whatever opens the doc in the IFRAME must run on the server and
check the location before loading. For example, if you load the
iframe by a user clicking a link, set all your links to one document
(say, checkIt.jsp? page=http://server.com/whatever.html)
I do all loading of the IFRAME through a Struts action, so I could
actually do it a bit more cleanly than this. I could add the checking
to the action.
and send the url they want to load as a parameter. Have checkIt.jsp
check that location. If it exists, change location to that page, if
not display error. The same can be done with button clicks, etc.


OK, that's an idea.

But it would require an HTTP access from the JSP container to the
source that is to be loaded inside the IFRAME. And that's too costly
in terms of response time, I think.

But thanx for the tip.
- Steinar
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3952
by: maxim vexler | last post by:
I'm reading a lot of talks lately about the term iFrame and with your permission would like to ask a few question about that : - what is iFrame, i mean what is it good for ? - does all the popular browsers support it (mostly mozilla & the much hated IE, google says the do but nothing is better that experienced answer) - iFrames replaces the old frames once used in html to show a number of pages in a single windows, right ? - what are...
0
2103
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4 IFRAMES and 2 IMGs tags. The problem is that the second IFRAME from the second page generates fires a new session.
7
3696
by: Scott | last post by:
Hello All, I've been reading all of the various issues with Iframes in netscape. I have tried all of the various fixes posted, and have even implemented both an iframe and ilayer. My problem is that no matter which i use, i can access the src before and after i change it, but the page never displays. in IE6 it works no matter how i access it. here is the code that is changing it: function InternalNav(sPage) {
5
2236
by: Frances | last post by:
I need to replace iframes acc. to what option user chooses in a sel obj.. but figured have to load a blank iframe when pg loads so I can replace it.. (iframe gets put in a pre-existing div..) this is approach.. I'm having some problems and would appreciate some help.. thank you very much... var selItem; var ifrCurr; var div = document.getElementById("divPricing"); // this var not being read inside functions..
2
2097
by: Guadala Harry | last post by:
1. Are IFrames supported only in uplevel versions of IE? If not IE exclusively, what browsers support IFrames? 2. Are IFrames going to be supported in the future - as far as anyone knows - or have they been deprecated and will no longer be supported in the future? Please note that I'm *not* asking for opinions on the merits of using IFrames or IFrames vs regular framesets or any other such...
3
2151
by: Giggle Girl | last post by:
Is there a way to use Javascript to detect if a browser supports IFrames, or (if it DOES support them) that IFrame use is enabled? Thanks, Ann
2
2370
by: Eric Lilja | last post by:
Hello, consider this complete program: #include <iostream> #include <string> using std::cout; using std::endl; using std::string; class Hanna {
19
5948
by: wmanzo | last post by:
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up the page but I find that the iframes interfere with the getting the mouse coords from the screen which is essential in moving the scroll bar around. My test html is given below. With the iframe hidden the mouse coords are obtainable. With the...
2
13003
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh all of them - from the server (this could be on page refresh also) as the purpose is to reset the iframe to the original content in case the user clicked on a link in that iframe and changed it, but also in case there were updates to the original page...
0
9876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
1
10683
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10320
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7045
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4506
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.