HTTP Webserver Using Java

import*;import*; class myserver{public static void main(String str[]){ String myIp=null;int port=786;try{ //Get Systems current ip addressmyIp= Inet4Address.getLocalHost().getHostAddress();System.out.println(“Server is Running with “+ myIp +”:”+ port); //Create Server SocketServerSocket welcome = new ServerSocket(port); //Accept incomming connection SocketSocket sskt = welcome.accept(); PrintWriter out = new PrintWriter(sskt.getOutputStream()); //Create MIME type to describe that, This is HTML Codeout.println(“HTTP/1.1 200

Download webpage using java server socket.

Download webpage using java server socket.  import*;import*; class readWebPage{public static void main(String arg[]){try{ Socket s = new Socket(“″,8090);String line=””;BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter out = new PrintWriter(s.getOutputStream()); out.print(“GET /httpclient.htmlnn”);out.flush();System.out.println(“Reading File”);while((line = in.readLine())!=null){ System.out.println(line);} } catch(Exception e){System.out.println(e.toString());}}}

Java HTTP Server and Client

Create chat application using either TCP protocol Making simple chat application using “Socket” Programming. Here is the code for TCP/IP Server and Client.  GTU; Practical 1: Advance  Java : Create chat application using either TCP  protocol   Code of Server /* * To change this license header, choose License Headers in Project Properties. * To change

Demo of I18N (Internationalization) with JAVA

I18N is called Internationalization, which supports Multiparty language in your software. again its not convert one language to other language but Display selected language from “Properties” file. Crate file Copy the following code.    import java.util.*; public class I18nDemo { private static Locale aLocale; private static Locale frLocale; private static ResourceBundle Message; public static

Write a program to select & print the largest of the three nos. using Nested-If-Else statement

#include <stdio.h> #include <conio.h> void main(){ float a, b, c; printf(“Enter three numbers: “); scanf(“%f %f %f”, &a, &b, &c); if (a>=b) { if(a>=c) printf(“Largest number = %.2f”,a); else printf(“Largest number = %.2f”,c); } else { if(b>=c) printf(“Largest number = %.2f”,b); else printf(“Largest number = %.2f”,c); } getch(); }

Write a program to solve Quadratic Equation

#include<stdio.h> #include<math.h> void main(){ float a,b,c; float d,root1,root2; printf(“Enter a, b and c of quadratic equation: “); scanf(“%f%f%f”,&a,&b,&c); d = b * b – 4 * a * c; if(d < 0){ printf(“Roots are complex number.\n”); printf(“Roots of quadratic equation are: “); printf(“%.3f%+.3fi”,-b/(2*a),sqrt(-d)/(2*a)); printf(“, %.3f%+.3fi”,-b/(2*a),-sqrt(-d)/(2*a)); return 0; } else if(d==0){ printf(“Both roots are equal.\n”); root1

Write a program that reads two nos. from key board and gives their addition, subtraction, multiplication, division and modulo.

#include<stdio.h> #include<conio.h> void main() { int a,b,sub,mul,div,add,mod; clrscr(); printf(“Enter the value of a&b”); scanf(“%d%d”,&a,&b); sub=a-b; mul=a*b; div=a/b; add=a+b; mod=a%b; printf(“sub of a&b is%d”,sub); printf(“mul of a&b is%d”,mul); printf(“div of a&b is%d”,div); printf(“add of a&b is%d”,add); printf(“Module of a&b is%d”,mod); getch(); }