Meta refresh command.

I have build a basic web page with 2 links. The links are targeted to a relay, and once you click link the relay activates. The issue I am having, after the link is clicked I get to a blank page.

Problem: I want to be redirected back to the original page once it is executed. I have heard <meta = Refresh command would do this but it keeps refreshing the original page. Maybe the <meta = Refresh command is not want I want? Maybe I should keep it simple and have it redirect to the orginal page once done. (dumb question; how do I do that?)

else if (req.indexOf("/Full") != -1){  //brings to Webpage 192.168.1.59/Full
   client.flush();
   client.println("HTTP/1.1 200 OK");
   client.println("");
   client.println("<html>");
   client.println("<HEAD>");  
   client.println("<TITLE>Garage Door</TITLE>");
   client.println("</HEAD>");
   client.println("<BODY>");
      

    String s1 = "Garage Door 1 is ";
    s1 += (Door1_Status);
    s1 += "</html>\n";
    client.println(s1);
   
   client.println("

");
   
   String s2 = "Garage Door 2 is ";
    s2 += (Door2_Status);
    s2 += "</html>\n";
    client.println(s2);
    delay(1);

  client.println("

");
  client.println("<h1>Click <a href=\"/gpio/3\">here</a> trigger Right Garage door
</h1>");
  client.println("</BODY>");
  client.println("</html>");
   
   Serial.println("Client disonnected");

    Serial.print("Door No. ");
    Serial.println(Door);
    Serial.println(s);}

else if (req.indexOf("/gpio/3") != -1){    //This is where the target of the link. I will trigger a relay
    val = 1;
    Door = 1;
    digitalWrite(Door1trigger, val);
    delay (500);
    val = 0;
    digitalWrite(Door1trigger, val);
    client.flush();
 
   client.print ("<meta HTTP-EQUIV='REFRESH\' content='0; url=http://192.168.1.59/Full>");   
    //i think this is wrong.  I need it to go back to the "/Full" page.  How do I do that??
    
delay(1);
    Serial.println("Client disonnected");}

I have heard <meta = Refresh command would do this

Then, you heard incorrectly. The refresh tag tells the browser to call the server again after the specified interval IF the current page is still being displayed.

    String s1 = "Garage Door 1 is ";
    s1 += (Door1_Status);
    s1 += "</html>\n";
    client.println(s1);
   
   client.println("

");

Why do you bother sending more data after the closing html tag?

(Why) (is) (Door1_Status) (in) (parentheses) (?)

  client.println("<h1>Click <a href=\"/gpio/3\">here</a> trigger Right Garage door
</h1>");

Why do you do a redirect, if you don't want a redirect to happen?

Maybe i have explained it incorrectly.

What I want is. After the command is finished I want it to return to 192.168.1.58/Full.htm

else if (req.indexOf("/gpio/3") != -1){ //This is where the target of the link. I will trigger a relay
val = 1;
Door = 1;
digitalWrite(Door1trigger, val);
delay (500);
val = 0;
digitalWrite(Door1trigger, val);
client.flush();

// after this command is done, don't go to a blank page, instead goto http://192.168.1.59/Full

What command do i use to bring we back to page 192.168.1.59/Full

Maybe i have explained it incorrectly.

What I want is. After the command is finished I want it to return to 192.168.1.58/Full.htm

Then get rid of the re-direct action. The href value in this statement

  client.println("<h1>Click <a href=\"/gpio/3\">here</a> trigger Right Garage door
</h1>");

is what causes the redirect.

I have developed a Web page. In the webpage there is a hyper link (called gpio3)

When clicking on the gpio3 link it will trigger a relay to open the garage door called "digitalWrite(Door1trigger, val);". Once this is complete I want it to return to the /Full page.

Once it returns to the /Full page the Arduino will refresh and indicate if the garage door is either open or closed. If I want to open/close the garage door again, all I need to do is click on the link again to activate the relay.

Currently:
I have the webpage with the hyper link. I click on the link which triggers the relay, but brings me to a blank page and doesn't redirect me back to the /Full.html site.

html.pdf (46.2 KB)

You don't appear to be sending the HTTP response line when you send the redirect tag.

the redirect didn't work

This page shows how to correctly write an HTML page that uses meta refresh to redirect:
https://www.w3.org/TR/WCAG20-TECHS/H76.html

So for example.
After the Relay is triggered wait 600ms then goto Google.com

Is this correct? (because I still get to a dead page.)

else if (req.indexOf("/gpio/3") != -1){
val = 1;
Door = 1;
Serial.print("Door No. ");
Serial.println(Door);
digitalWrite(Door1trigger, val);
delay (500);
val = 0;
digitalWrite(Door1trigger, val);
client.flush();
delay(600);
Serial.println (" ") ;

Serial.println("Client disonnected");

Is this correct?

Why are trying to redirect to google's site?

Have you stopped making the button do a different re-direct?

angipp01:
Is this correct? (because I still get to a dead page.)

else if (req.indexOf("/gpio/3") != -1){

val = 1;
   Door = 1;
 Serial.print("Door No. ");
 Serial.println(Door);
   digitalWrite(Door1trigger, val);
   delay (500);
   val = 0;
   digitalWrite(Door1trigger, val);
   client.flush();
   delay(600);
   Serial.println (" ") ;
   
   Serial.println("Client disonnected");

No, because you left out 90% of the HTML page:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>      
    <title>The Tudors</title>      
    <meta http-equiv="refresh" content="0;URL='http://thetudors.example.com/'" />    
  </head>    
  <body> 
    <p>This page has moved to a <a href="http://thetudors.example.com/">
      theTudors.example.com</a>.</p> 
  </body>  
</html>

And you should probably put the 'meta' tag in the header and your text in the body.

PaulS:
Why are trying to redirect to google's site?

Have you stopped making the button do a different re-direct?

Why google? It is just an example. Google is not the point of the post. The point of the post is that I want it to redirect to a specific site. I choose Google to simply things.

johnwasser:
No, because you left out 90% of the HTML page:

<html xmlns="http://www.w3.org/1999/xhtml">

     
    The Tudors     
       
     
 
   

This page has moved to a
      theTudors.example.com
.


 

> ``` > > > > And you should probably put the 'meta' tag in the header and your text in the body.

Thanks for you help. I did what you directed. The page doesn't redirect to google.com after my "digitalWrite" was executed. This is what I created. Can you tell me what I did wrong. I put the meta command in both body and header as you directed.

else if (req.indexOf("/gpio/3") != -1){
val = 1;
digitalWrite(Door1trigger, val);
delay (500);
val = 0;
digitalWrite(Door1trigger, val);
client.flush();
delay(1000);
client.println("HTTP/1.1 200 OK");
client.println("");
client.println("");
client.println("");
client.println("Garage Door");
Serial.print(" ") ;
client.println("");
client.println("");
Serial.print(" ") ;
client.println("");
client.println("");
Serial.println("Client disonnected");

Can someone assist me in what to do. The above coding has all HTML + Meta refresh and still doesn't work.

You're coming uncomfortably close to demanding help.
This site isn't staffed by a tech support forum.
Most that assist also have lives that exist outside the forum.

I'm this close to speaking out against those who toss their problems over the wall not only hoping that someone will help but many times expecting someone to do their research and debug and revamp their code for them.

Whoops, I just did ...

Thanks, I like when they help me and give me direction. But I have a problem when I follow there direction and code it as per their direction and when it doesn't work. They are high and dry.

Thanks everyone on this post for assisting me. I have don't know what I did wrong. I have done these steps over and over and again. Now it is working.

else if (req.indexOf("/gpio/4") != -1){
val = 1;
digitalWrite(Door2trigger, val);
delay (500);
val = 0;
digitalWrite(Door2trigger, val);
client.flush();
delay(1000);
client.println("HTTP/1.1 200 OK");
client.println("");
client.println("");
client.println("");
client.println("Garage Door");
client.println("");
client.println("");
client.println(" ") ;
client.println("");
client.println("");
Serial.println("Client disonnected");