How to redirect from a HTML page?

How to redirect from a HTML page?

Hi,

Is it possible to redirect from HTML page to another page on the net? I have one page and I want to redirect it to another page. What will be the code for redirecting the page to another page when use visits the first page.

Thanks

View Answers

October 8, 2013 at 10:35 PM

Yes, Its possible to redirect to another page using HTML code. You can use the following code:

<meta http-equiv="refresh" content="0; url=http://www.roseindia.net/">

The tag <meta http-equiv="refresh" />is used to refresh the browser after specified interval. Following code will refresh the page after 60 seconds:

<head>
<meta http-equiv="refresh" content="60">
</head>

This is one of the easiest way to refresh the page or redirect one page to another page.

Hope above code will help you.

View more tutorials at HTML tutorial index page.

Thanks


October 8, 2013 at 10:41 PM

Hi,

JavaScript can also be used to redirect the page to another page.

Here is the complete code example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>Example of HTML page redirect</TITLE>
        <script language="JavaScript">
        window.location.href = "http://www.roseindia.net"
        </script>
    </HEAD>

 <BODY>
  <P><a href='http://example.com'>Click here to visit another page</a></p>
 </BODY>
</HTML>

Here we are using window.location.href = "http://www.roseindia.net"for redirecting to another page.

When page loads JavaScript is executed and page is redirected to http://www.roseindia.net

Thanks


October 8, 2013 at 10:47 PM

Hi,

Another option is to use the HTTP 301 redirect. This solution is based on the Server Side solution of redirect. The Sever instruct the browser that the resource is permanently move to another url.

Client requests for the a resource on server:

GET /mypage.php HTTP/1.1
Host: www.roseindia.net

Server response:

HTTP/1.1 301 Moved Permanently
Location: http://www.roseindia.net/anotherresource.html

You can use the following code in your Servlet for this purpose:

response.sendRedirect("/ServletProject/ValidUser");

Here is an example of Send Redirect in Servlet.

Thanks









Related Tutorials/Questions & Answers:
How to redirect from a HTML page?
How to chage content in HTML pages?
Advertisements
HTML pages.
dynamic web pages in html
jquery search for html pages
How to retrieve kernal memory details(paged and non-paged ) using SIGAR API in java program
Redirect from servlet to servlet
redirect to multiple links from servlet
how to send html email from dreamweaver
how to fetch values from .properties to a html file
How to hide HTML code from user? - Security
how to save web pages in a partcular document in html format using java.. - Java Beginners
how to redirect jsp page to extjs
How to export data from html to excel sheet by using java
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java
Pager taglib - Java Beginners
How to extract HTML elements from a page?
How to extract HTML elements from a page?
ModuleNotFoundError: No module named 'orbis-plugin-storage-html-pages'
ModuleNotFoundError: No module named 'pager'
How to retrieve array values from html form to jsp?
How to pass parametes from JSP page to HTML page? - JSP-Servlet
Badge from html content
Jsp redirect
how to call servlet from html page at anchor tag ?
extract data from HTML
how to pass form values from javascript of html page to jsp page
ModuleNotFoundError: No module named 'lazy-paged-sequence'
ModuleNotFoundError: No module named 'lazy-paged-sequence'
ModuleNotFoundError: No module named 'ldap_paged_search'
ModuleNotFoundError: No module named 'ldap_paged_search'
How to send the data selected from drop down menu from html page to sql 2005 database.
ACCESS DATABASE FROM HTML
how to retrive data grom database in jsp pages.
ModuleNotFoundError: No module named 'django-pager'
ModuleNotFoundError: No module named 'fluentcms-pager'
passing parameter from html to applet
how to do this - JavaMail
Removing HTML from a Java String
how to retrieve image from mysql database using java and show it in HTML img tag ?
ModuleNotFoundError: No module named 'compare_man_pages_from_two_folders'
ModuleNotFoundError: No module named 'compare_man_pages_from_two_folders'
ModuleNotFoundError: No module named 'compare_man_pages_from_two_folders'
Hi how to transfer table data from html page to excel sheet by using javascript .
How many ways I can redirect a PHP page?
Get values from JSP pages - JSP-Servlet
how to scrape the data from one website another website using html dom parsing in php
How to get the text from textarea in HTML and store it in database using javascript and jsp
ModuleNotFoundError: No module named 'ws-grid-pager'

Ads