Control led from JSP

i’m trying to send measured data at Arduino to JSP (using Eclipse and Apache Tomcat server) using HTTP GET and server send control LED signal values to the Arduino at the same time .

There is no compile error
but led control doesn’t work
the problem is that i don’t know what is the problem…

here is the code

#include <SPI.h>
#include <Ethernet.h>
#define led_pin 8

  IPAddress server2(192, 168, 21, 6); 
  IPAddress ip(192, 168, 21, 4);
  EthernetServer server(80);
  EthernetClient client;
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};

  boolean incoming = 0;
  unsigned long prevMillis = 0;
  const long interval = 1000;
  
void setup() {
  Serial.begin(9600);
  pinMode(led_pin, OUTPUT);

  //Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
}

void loop() {

    unsigned long currentMillis = millis();
    EthernetClient client = server.available();

    int val1=analogRead(0);
    // int val2=analogRead(1);
    int val2=0;

    if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
    }

    if (currentMillis - prevMillis >= interval) {
    // save the last time you blinked the LED
    prevMillis = currentMillis;
  
    if (client.connect(server2, 8080)) {
    //Serial.println("connected");
    client.print("GET /FloorNoise/FloorNoiseMain.jsp?val=");
    client.print(val1);
    client.print("&vive=");
    client.print(val2);
    client.println("&adr=106_301");
    //client.println("HTTP/1.1");
    //client.println("Host: 192.168.21.6");
    client.println();
  
  } else {
    Serial.println("connection failed");
  }
/*
  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read();
    Serial.print(c);
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop();
*/
 /* if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    while (true);
  }*/
    }
  
   if (client = server.available()) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        
        if (incoming && c == ' ') {
          incoming = 0;
        }
        if (c == '

Ps : My English is not good. I would greatly appreciate it if you kindly give me some help) {
          incoming = 1;
        }
       
        if (incoming == 1) {
          Serial.println(c);

if (c == ‘1’) {
            Serial.println(“ON”);
            digitalWrite(led_pin, HIGH);
          }
          if (c == ‘2’) {
            Serial.println(“OFF”);
            digitalWrite(led_pin, LOW);
          }
        }
      }
    }
    client.stop();
  }
}


Ps : My English is not good. I would greatly appreciate it if you kindly give me some help

Try telnet-ing to your server and type the GET command as you are trying to send it from Arduino

If that does not work as you expect (i.e. You don't get the return HTML page), then figure out how to write that well formatted GET command your server expects.

Many HTTP servers nowadays expect a well formed GET request including Host and User-Agent (don't forget the empty line at the end)

Once you have understood what your server expects as a well formed GET request, inject that in your code and test again.

Are you really going to spam the server with HTTP requests as fast as the arduino is able to make them :0 ? At the very very least, include a if(millis()-timeOfLastRequest<1000L) return; on the main.