Board Logo
« Ugly webserver... »

Welcome Guest. Please Login or Register.
Feb 25th, 2018, 7:58pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Ugly webserver...  (Read 258 times)
code
Member in Training
ImageImage


member is offline

Avatar




Homepage PM


Posts: 23
xx Ugly webserver...
« Thread started on: Jan 18th, 2018, 12:15pm »

Hi,

If you want some text displayed in your browser(for example Firefox) then compile the code below on https://www.compilejava.net/(This will be the webserver...)

Code:
import java.io.*;
import java.net.*;
import java.util.Date;
public class basic {
    public static void main(String args[]){

        ServerSocket ser = null;
        String ld;
        DataInputStream dis;
        PrintStream ps;
        Socket cs = null;

        try {ser = new ServerSocket(80);}
        catch (IOException e) {}   

      while(true){
      
    try {
           cs = ser.accept();
           dis = new DataInputStream(cs.getInputStream());
           ps = new PrintStream(cs.getOutputStream());
           Date d = new Date();
           
             //ld = dis.readLine();
             ps.println("Justbasic... "+d.toString()); 
           cs.close();
          
        }   
    catch (IOException e) {
           
    }}
    }
}


 


To start it open a 'DOS-window' ,go to the directory where basic.class is unzipped... and run it with the command:
'C:\adir\java basic' (not java basic.class just :java basic).

Then open a browser and type: http://localhost and enter.
Now you may see the text :Justbasic

To see the 'website' from over the world , you have to do:
port forwarding... like: http://467.245.67.89 search for a video who explains it.

Goodluck !

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls