ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yesterday I setup a web server on my home computer, and I'm going to host part of my home page on this server. I say part of since I already have a web page at work which I still want to use, since this has a much better URL. The problem is now that my computer at home is usually switched off when I'm not at home, which will give a lot of errors when someone tries to follow a link from my web page at work, to a page which is on my switched-off home computer.
My question is: is it possible to write something in html/xml/asp/jsp/javascript/whatever, that redirects to my home computer's web page if it is running, but displays another page if it's off? Something like
Code:
if home_server_responds then
redirect to web page on home server
else
display another page on the work web page
You could try pinging your server (system("ping")), and parse the respond you get. If you get something like 'unable to find the server' redirect them.
you could write a simple java servlet/JSP for your work computer which would wait for an HTTP request, then once it gets one tries to open that URL (with a very short timeout). If it times out or blows up then send a redirect to the work computer's page, else read the contents of the page and display them. That also has the advantage of making it look like the stuff from your home puter is on the work computer, with the nice URL.
Thanks guys for your reply! But...my knowledge about programming web pages in anything other than html and css is very bad, so can you give me an example of how to do it, or direct me to some tutorial/how-to where I can find the info myself?
Yes, this is indeed a forgotten thread, but thanks a lot for the reply! Unfortunately I have nowhere to test it at the moment, but some day, some day...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.