understanding of Client-Server Program

Thread Starter

daljeet795

Joined Jul 2, 2018
295
I need some help getting started. I've been researching client and server site scripting and trying to understand how they communicate. but I didn't understand the basic. I just started with the basic example. It just return "Welcome !" message on the web browser

A client (browser) send request to the server; then the server returns a response to the client. POST requests are used to send data to the sever . GET request is what we get when we enter a URI in your browser or when we click on a link on a web page

I want to write code when I click button, Server would be display "Welcome !" message on web browser.

How to make complete program so that it can be run on any web server ?
client site script
HTML:
<!DOCTYPE html>
<html>
<body>

<h2>Press Button</h2>
<form action="button">
    <button type="submit">Button</button>
<form>
</body>
</html>
Server site scripting
Code:
public class HelloWorld {

    public static void main(String[] args) {
         System.out.println( "Welcome!" );
            System.exit( 0 ); //success

    }

}
 
You might want to start by taking a look at some of the many examples of HTML client/server programming using the ubiquitous ESP8266. For example, here

Code:
void handleRoot() {
server.send(200, "text/plain", "Hello world!"); // Send HTTP status 200 (Ok) and send some text to the browser/client
}
 

wayneh

Joined Sep 9, 2010
17,498
I need some help getting started. I've been researching client and server site scripting and trying to understand how they communicate. but I didn't understand the basic. I just started with the basic example. It just return "Welcome !" message on the web browser

A client (browser) send request to the server; then the server returns a response to the client. POST requests are used to send data to the sever . GET request is what we get when we enter a URI in your browser or when we click on a link on a web page

I want to write code when I click button, Server would be display "Welcome !" message on web browser.

How to make complete program so that it can be run on any web server ?
client site script
HTML:
<!DOCTYPE html>
<html>
<body>

<h2>Press Button</h2>
<form action="button">
    <button type="submit">Button</button>
<form>
</body>
</html>
Server site scripting
Code:
public class HelloWorld {

    public static void main(String[] args) {
         System.out.println( "Welcome!" );
            System.exit( 0 ); //success

    }

}
I've forgotten a lot of my html, but I think your FORM isn't setup properly. It should be either a POST or a GET, I think, and it should tell the server what to do expect, like this:

Code:
  <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
 

Thread Starter

daljeet795

Joined Jul 2, 2018
295
You might want to start by taking a look at some of the many examples of HTML client/server programming using the ubiquitous ESP8266. For example, here
I've forgotten a lot of my html, but I think your FORM isn't setup properly. It should be either a POST or a GET, I think, and it should tell the server what to do expect, like this:
I am not familiar with code you posted, That's what I want to start with simple program. client site scripting is not problem server site scripting is difficult to understand. I can print the Welcome message in any language like java, c, c++, php, pyhon

I know I have to add some lines of code in my server program so that this code will run on the server.I am not able to understand what I have to add. I want this help from you so at least i can get the start

Can you help me in this program code
 
Top