Sunday, March 4, 2018

Something Very useful information

कई दिनों के मेहनत के बाद ये मैसेज तैयार किया है दोस्तों आपसे निवेदन है की ये मैसेज सभी छात्रो तक पहुँचाऐ      
1. (α+в)²= α²+2αв+в²
2. (α+в)²= (α-в)²+4αв
3. (α-в)²= α²-2αв+в²
4. (α-в)²= (α+в)²-4αв
5. α² + в²= (α+в)² - 2αв.
6. α² + в²= (α-в)² + 2αв.
7. α²-в² =(α + в)(α - в)
8. 2(α² + в²) = (α+ в)² + (α - в)²
9. 4αв = (α + в)² -(α-в)²
10. αв ={(α+в)/2}²-{(α-в)/2}²
11. (α + в + ¢)² = α² + в² + ¢² + 2(αв + в¢ + ¢α)
12. (α + в)³ = α³ + 3α²в + 3αв² + в³
13. (α + в)³ = α³ + в³ + 3αв(α + в)
14. (α-в)³=α³-3α²в+3αв²-в³
15. α³ + в³ = (α + в) (α² -αв + в²)
16. α³ + в³ = (α+ в)³ -3αв(α+ в)
17. α³ -в³ = (α -в) (α² + αв + в²)
18. α³ -в³ = (α-в)³ + 3αв(α-в)
ѕιη0° =0
ѕιη30° = 1/2
ѕιη45° = 1/√2
ѕιη60° = √3/2
ѕιη90° = 1
¢σѕ ιѕ σρρσѕιтє σƒ ѕιη
тαη0° = 0
тαη30° = 1/√3
тαη45° = 1
тαη60° = √3
тαη90° = ∞
¢σт ιѕ σρρσѕιтє σƒ тαη
ѕє¢0° = 1
ѕє¢30° = 2/√3
ѕє¢45° = √2
ѕє¢60° = 2
ѕє¢90° = ∞
¢σѕє¢ ιѕ σρρσѕιтє σƒ ѕє¢
2ѕιηα¢σѕв=ѕιη(α+в)+ѕιη(α-в)
2¢σѕαѕιηв=ѕιη(α+в)-ѕιη(α-в)
2¢σѕα¢σѕв=¢σѕ(α+в)+¢σѕ(α-в)
2ѕιηαѕιηв=¢σѕ(α-в)-¢σѕ(α+в)
ѕιη(α+в)=ѕιηα ¢σѕв+ ¢σѕα ѕιηв.
» ¢σѕ(α+в)=¢σѕα ¢σѕв - ѕιηα ѕιηв.
» ѕιη(α-в)=ѕιηα¢σѕв-¢σѕαѕιηв.
» ¢σѕ(α-в)=¢σѕα¢σѕв+ѕιηαѕιηв.
» тαη(α+в)= (тαηα + тαηв)/ (1−тαηαтαηв)
» тαη(α−в)= (тαηα − тαηв) / (1+ тαηαтαηв)
» ¢σт(α+в)= (¢σтα¢σтв −1) / (¢σтα + ¢σтв)
» ¢σт(α−в)= (¢σтα¢σтв + 1) / (¢σтв− ¢σтα)
» ѕιη(α+в)=ѕιηα ¢σѕв+ ¢σѕα ѕιηв.
» ¢σѕ(α+в)=¢σѕα ¢σѕв +ѕιηα ѕιηв.
» ѕιη(α-в)=ѕιηα¢σѕв-¢σѕαѕιηв.
» ¢σѕ(α-в)=¢σѕα¢σѕв+ѕιηαѕιηв.
» тαη(α+в)= (тαηα + тαηв)/ (1−тαηαтαηв)
» тαη(α−в)= (тαηα − тαηв) / (1+ тαηαтαηв)
» ¢σт(α+в)= (¢σтα¢σтв −1) / (¢σтα + ¢σтв)
» ¢σт(α−в)= (¢σтα¢σтв + 1) / (¢σтв− ¢σтα)
α/ѕιηα = в/ѕιηв = ¢/ѕιη¢ = 2я
» α = в ¢σѕ¢ + ¢ ¢σѕв
» в = α ¢σѕ¢ + ¢ ¢σѕα
» ¢ = α ¢σѕв + в ¢σѕα
» ¢σѕα = (в² + ¢²− α²) / 2в¢
» ¢σѕв = (¢² + α²− в²) / 2¢α
» ¢σѕ¢ = (α² + в²− ¢²) / 2¢α
» Δ = αв¢/4я
» ѕιηΘ = 0 тнєη,Θ = ηΠ
» ѕιηΘ = 1 тнєη,Θ = (4η + 1)Π/2
» ѕιηΘ =−1 тнєη,Θ = (4η− 1)Π/2
» ѕιηΘ = ѕιηα тнєη,Θ = ηΠ (−1)^ηα
1. ѕιη2α = 2ѕιηα¢σѕα
2. ¢σѕ2α = ¢σѕ²α − ѕιη²α
3. ¢σѕ2α = 2¢σѕ²α − 1
4. ¢σѕ2α = 1 − ѕιη²α
5. 2ѕιη²α = 1 − ¢σѕ2α
6. 1 + ѕιη2α = (ѕιηα + ¢σѕα)²
7. 1 − ѕιη2α = (ѕιηα − ¢σѕα)²
8. тαη2α = 2тαηα / (1 − тαη²α)
9. ѕιη2α = 2тαηα / (1 + тαη²α)
10. ¢σѕ2α = (1 − тαη²α) / (1 + тαη²α)
11. 4ѕιη³α = 3ѕιηα − ѕιη3α
12. 4¢σѕ³α = 3¢σѕα + ¢σѕ3α

» ѕιη²Θ+¢σѕ²Θ=1
» ѕє¢²Θ-тαη²Θ=1
» ¢σѕє¢²Θ-¢σт²Θ=1
» ѕιηΘ=1/¢σѕє¢Θ
» ¢σѕє¢Θ=1/ѕιηΘ
» ¢σѕΘ=1/ѕє¢Θ
» ѕє¢Θ=1/¢σѕΘ
» тαηΘ=1/¢σтΘ
» ¢σтΘ=1/тαηΘ
» тαηΘ=ѕιηΘ/¢σѕΘ
"महत्वपूर्ण"..

9th,10th,11th,12th, गणित विषय के सारे फॉर्मूले है..
कृपया करके सभी बच्चों के parents को जरूर share करें और बच्चों को दिखाने को कहें।
धन्यवाद 
साथियों बहुत महत्वपूर्ण जानकारी है उम्मीद करता हूं आखिर तक पढकर आगे पोस्ट करोगे.
» B. A. — Bachelor of Arts.
» M. A. — Master of Arts. »B.tech - Bachelor of Technology
» B. Sc. — Bachelor of Science
» M. Sc. — Master of Science
» B. Sc. Ag. — Bachelor of Science in Agriculture
» M. Sc. Ag. — Master of Science in Agriculture
» M. B. B. S. — Bachelor of Medicine and Bachelor of Surgery
» B.A.M.S- Bachelor of Ayurved Medicine and surgery
» M. D. — Doctor of Medicine
» M. S. — Master of Surgery
» Ph. D. / D. Phil. — Doctor of Philosophy (Arts & Science)
» D. Litt./Lit. — Doctor of Literature / Doctor of Letters
» D. Sc. — Doctor of Science
» B. Com. — Bachelor of Commerce
» M. Com. — Master of Commerce
» Dr. — Doctor
» B. P. — Blood Pressure
» Mr. — Mister
» Mrs. — Mistress
» M.S. — miss (used for female married & unmarried)
» Miss — used before unmarried girls)
» M. P. — Member of Parliament
» M. L. A. — Member of Legislative Assembly
» M. L. C. — Member of Legislative Council
» P. M. — Prime Minister
» C. M. — Chief Minister
» C-in-C — Commander-In-Chief
» L. D. C. — Lower Division Clerk
» U. D. C. — Upper Division Clerk
» Lt. Gov. — Lieutenant Governor
» D. M. — District Magistrate
» V. I. P. — Very Important  Person
» I. T. O. — Income Tax Officer
» C. I. D. — Criminal Investigation Department
» C/o — Care of
» S/o — Son of
» C. B. I. — Central Bureau of Investigation
» G. P. O. — General Post Office
» H. Q. — Head Quarters
» E. O. E. — Errors and Omissions Excepted
» Kg. — Kilogram
» KW. — Kilowatts
Gm. — Gram
Km. — Kilometer
Ltd. — Limited
M. P. H. — Miles Per Hour
KM. P. H. — Kilometre Per Hour
P. T. O. — Please Turn Over
P. W. D. — Public Works Department
C. P. W. D. — Central Public Works Department
U. S. A. — United States of America
U. K. — United Kingdom (England)
U. P. — Uttar Pradesh
M. P. — Madhya Pradesh
H. P. — Himachal Pradesh
U. N. O. — United Nations Organization
W. H. O. — World Health Organization
B. B. C. — British Broadcasting Corporation
B. C. — Before Christ
A. C. — Air Conditioned
I. G. — Inspector General (of Police)
D. I. G. — Deputy Inspector General (of Police)
S. S. P. — Senior Superintendent of Police
D. S. P. — Deputy Superintendent of Police
S. D. M. — Sub-Divisional Magistrate
S. M. — Station Master
A. S. M. — Assistant Station Master
V. C. — Vice-Chancellor
A. G. — Accountant General
C. R. — Confidential Report
I. A. S. — Indian Administrative Service
I. P. S. — Indian Police Service
I. F. S. — Indian Foreign Service or Indian Forest Service
I. R. S. — Indian Revenue Service
P. C. S. — Provincial Civil Service
M. E. S. — Military Engineering Service
☀Full Form Of Some technical Words
» VIRUS - Vital Information Resource Under Seized.
» 3G -3rd Generation.
» GSM - Global System for Mobile Communication.
» CDMA - Code Division Multiple Access.
» UMTS - Universal Mobile Telecommunication System.
» SIM - Subscriber Identity Module .
» AVI = Audio Video Interleave
» RTS = Real Time Streaming
» SIS = Symbian
OS Installer File
» AMR = Adaptive Multi-Rate Codec
» JAD = Java Application Descriptor
» JAR = Java Archive
» JAD = Java Application Descriptor
» 3GPP = 3rd Generation Partnership Project
» 3GP = 3rd Generation Project
» MP3 = MPEG player-3
» MP4 = MPEG-4 video file
» AAC = Advanced Audio Coding
» GIF= Graphic Interchangeable Format
» JPEG = Joint Photographic Expert Group
» BMP = Bitmap
» SWF = Shock Wave Flash
» WMV = Windows Media Video
» WMA = Windows Media Audio
» WAV = Waveform Audio
» PNG = Portable Network Graphics
» DOC =Document (Microsoft Corporation)
» PDF = Portable Document Format
» M3G = Mobile 3D Graphics
» M4A = MPEG-4 Audio File
» NTH = Nokia Theme (series 40)
» THM = Themes (Sony Ericsson)
» MMF =Synthetic Music Mobile Application File
» NRT = Nokia Ringtone
» XMF = Extensible Music File
» WBMP = Wireless Bitmap Image
» DVX = DivX Video
» HTML = Hyper Text Markup Language
» WML =Wireless Markup Language
» CD -Compact Disk.
» DVD - Digital Versatile Disk.
» CRT - Cathode Ray Tube.
» DAT - Digital Audio Tape.
» DOS - Disk Operating System.
» GUI -Graphical
User Interface.
» HTTP - Hyper Text Transfer Protocol.
» IP - Internet Protocol.
» ISP - Internet Service Provider.
» TCP - Transmission Control Protocol.
» UPS - Uninterruptible Power Supply.
» HSDPA -High Speed Downlink Packet Access.
» EDGE - Enhanced Data Rate for Evolution.
» GSM- [Global System for Mobile Communication]
» VHF - Very High Frequency.
» UHF - Ultra HighFrequency.
» GPRS - General Packet Radio Service.
» WAP - Wireless Application Protocol.
» TCP - Transmission Control Protocol.
» ARPANET - Advanced Research Project Agency Network.
» IBM - International Business Machines.
» HP - Hewlett Packard.
» AM/FM - Amplitude/ Frequency Modulation
☝Whatsapp ke itihaas me pahli baar....kaam ka msg.........
Here are Toll Free numbers in India
.....very very useful...!!!!
☀Airlines
Indian Airlines - 1800 180 1407
Jet Airways - 1800 225 522
Spice Jet - 1800 180 3333
Air India - 1800 227 722
Kingfisher -1800 180 0101
☀Banks
ABN AMRO - 1800 112 224
Canara Bank - 1800 446 000
Citibank - 1800 442 265
Corporation Bank - 1800 443 555
Development Credit Bank - 1800
225 769
HDFC Bank - 1800 227 227
ICICI Bank - 1800 333 499
ICICI Bank NRI -1800 224 848
IDBI Bank -1800 116 999
Indian Bank -1800 425 1400
ING Vysya -1800 449 900
Kotak Mahindra Bank - 1800 226
022
Lord Krishna Bank -1800 112 300
Punjab National Bank - 1800 122
222
State Bank of India - 1800 441 955
Syndicate Bank - 1800 446 655
☀Automobiles
Mahindra Scorpio -1800 226 006
Maruti -1800 111 515
Tata Motors - 1800 255 52
Windshield Experts - 1800 113 636
☀Computers / IT
Adrenalin - 1800 444 445
AMD -1800 425 6664
Apple Computers-1800 444 683
Canon -1800 333 366
Cisco Systems- 1800 221 777
Compaq - HP -1800 444 999
Data One Broadband - 1800 424
1800
Dell -1800 444 026
Epson - 1800 44 0011
eSys - 3970 0011
Genesis Tally Academy - 1800 444
888
HCL - 1800 180 8080
IBM - 1800 443 333
Lexmark - 1800 22 4477
Marshal's Point -1800 33 4488
Microsoft - 1800 111 100
Microsoft Virus Update - 1901 333
334
Seagate - 1800 180 1104
Symantec - 1800 44 5533
TVS Electronics-1800 444 566
WeP Peripherals-1800 44 6446
Wipro - 1800 333 312
Xerox - 1800 180 1225
Zenith - 1800 222 004
☀Indian Railways
General Enquiry 139
Central Enquiry 131
Reservation 139
Railway Reservation Enquiry 1345,
1335, 1330
Centralised Railway Enquiry 133, 1,
2, 4, 5, 6, 7, 8 & 9
Couriers / Packers &
Movers
ABT Courier - 1800 448 585
AFL Wizz - 1800 229 696
Agarwal Packers & Movers - 1800
114 321
Associated Packers P Ltd - 1800 214
560
DHL - 1800 111 345
FedEx - 1800 226 161
Goel Packers & Movers - 1800 11
3456
UPS - 1800 227 171
☀Home Appliances
Aiwa/Sony - 1800 111 188
Anchor Switches - 1800 227 7979
Blue Star - 1800 222 200
Bose Audio - 112 673
Bru Coffee Vending Machines - 1800
4 7171
Daikin Air Conditioners - 1800 444
222
DishTV - 1800 123 474
Faber Chimneys - 1800 214 595
Godrej - 1800 225 511
Grundfos Pumps - 1800 334 555
LG - 1901 180 9999
Philips - 1800 224 422
Samsung - 1800 113 444
Sanyo - 1800 110 101
Voltas - 1800 334 546
......FORWARD TO ALL GROUPS AND FRIEND'S.
*✨* VK *✨*
[06/03/2017].
   भारत के प्रमुख पदाधिकारी
●●●●●●●●●●●●●●●●
 * राष्ट्रपति
Shri. Ramkrushna Kovind
 * उप राष्ट्रपति
Shri. Venkayya Naidu
 * प्रधान मंत्री
श्री नरेंद्र मोदी
 * लोकसभा अध्यक्ष
श्रीमती सुमित्रा महाजन
 * सर्वोच्च न्यायलय के मुख्य न्यायधीश
जस्टिस  जे०एस०खेहर
 * राष्ट्रीय मानवाधिकार आयोग के अध्यक्ष
श्री  एच.एल.दत्तू
 * राष्ट्रीय महिला आयोग के अध्यक्ष
श्रीमती ललिता कुमार मंगलम
 * मुख्य चुनाव आयुक्त
श्री एस. एन. जैदी
 * अटार्नी जनरल
श्री मुकुल रोहतगी
 * सोलिसिटर जनरल
श्री रनजीत कुमार
 * राष्ट्रीय विधि आयोग के अध्यक्ष
श्री बलबीर सिंह चौहान
 * राष्ट्रीय सुरक्षा सलाहकार
श्री अजीत कुमार डोभाल

[राज्य] [मुख्यमंत्री] {Updated }
     -------------------------------------
[1] महाराष्ट्र-- देवेंद्र फड़नवीस
[2] हरियाणा--मनोहरलाल खट्टर
[3] झारखण्ड —-श्री रघुवर दास
[4] जम्मू और कश्मीर —– महबूबा मुफ्ती
[5] हिमाचल प्रदेश —–वीरभद्र सिंह
[6] कर्नाटक —–के. सिद्धारमैया
[7] केरल —— पिनारायी विजयन
[8] मध्य प्रदेश -- शिवराज सिंह चौहान
[9] तेलंगाना -- चंद्रशेखर राव
[10] सीमांध्र - - चन्द्रबाबू नायडू
[11] अरुणाचल प्रदेश —-पेमा खांडु
[12] असम —- सरबानंद सोनवाल
[13] बिहार —– नीतीश कुमार
[14] छत्तीसगढ़ —-डॉ.रमन सिंह
[15] दिल्ली —arvind kejrival
[16] गोआ —– LakshmiKant
                        Parsekar.
[17] पॉण्डिचेरी - - वी. नारायनस्वामी
[18] पंजाब- - प्रकाश सिंह बादल
[19] राजस्थान -वसुंधरा राजेसिंधिया
[20] सिक्किम - पवन कुमार चामलिंग
[21] तमिलनाडु- के. पलानीस्वामी
[22] त्रिपुरा- - - माणिक सरकार
[23] उत्तराखण्ड —— हरीश रावत
[24] उत्तर प्रदेश- अखिलेश यादव
[25] पश्चिम बंगाल ——ममता बनर्जी,
[26] गुजरात —–विजय रुपानी
[27] मणिपुर —– ओकराम इबोई सिंह
[28] मेघालय —– मुकुल संगमा
[29] मिज़ोरम -- श्री लाल थानवाला
[30] नागालैण्ड —– शुरहोजेलइ लेइजेइत्सु
[31] ओडिशा —– नवीन पटनायक 
साथियों बहुत  महत्वपूर्ण जानकारी है उम्मीद करता हूं आगे जरूर पोस्ट करोगे    ✍   
  किसी के जीवन में आपके वजह से बहुत बड़ा काम हो जाये l
 फिजूल का संदेश तो रोजना भेजते हो लेकिन एक दिन अच्छा भेजो आपको बहुत सुकून मिलेगा।

Monday, March 20, 2017

Write a Socket program in java in which client accept a number, send it to the server, server calculates its factorial and sends result to the client.

factclient.java

        import java.io.*;
        import java.net.*;
class factclient{
    public static void main(String argv[]) throws Exception
    {
        String n;
        DatagramSocket clientSocket = new DatagramSocket();
        byte []send=new byte[102];
        byte []resive=new byte[102];
        BufferedReader inFromUser = new BufferedReader(new                InputStreamReader(System.in));
        System.out.println("\nEnter Number : ");
        n=inFromUser.readLine();
        InetAddress ipadd= InetAddress.getByName("localhost");
        send=n.getBytes();
        DatagramPacketsendPck=new DatagramPacket(send,send.length,ipadd,6870);
        clientSocket.send(sendPck);
        DatagramPacket resPck=new DatagramPacket(resive,resive.length);
        clientSocket.receive(resPck);
        String fact=new String(resPck.getData());
        System.out.println("FROM SERVER: " +n+"! = " +fact);
        clientSocket.close();
    }
}

       
 factserver.java

        import java.io.*;
        import java.net.*;
class factserver{
    public static void main(String argv[]) throws Exception
    {
        String num,res;
        int i,no;
        long fact;
        System.out.println("Server is ready");
        DatagramSocket serverSocket = new DatagramSocket(6870);
        byte []send=new byte[102];
        byte []resive=new byte[102];
        DatagramPacket resPck=new DatagramPacket(resive,resive.length);
        serverSocket.receive(resPck);
        num=new String(resPck.getData());
        num=num.trim();
        no=Integer.parseInt(num);
        fact=1;
        for(i=1;i<=no;i++)
            fact=fact*i;
        res=Long.toString(fact);
        send=res.getBytes();
        InetAddress ipadd= resPck.getAddress();
        int port=resPck.getPort();
        DatagramPacketsendPck=new DatagramPacket(send,send.length,ipadd,port);
        serverSocket.send(sendPck);
    }
}

Write a Socket program in java for chatting application. (Use AWT)

ClientChatForm.java

        import java.awt.event.ActionEvent;
        import java.awt.event.ActionListener;
        import java.awt.print.PrinterException;
        import java.io.DataInputStream;
        import java.io.DataOutputStream;
        import java.io.IOException;
        import java.net.InetAddress;
        import java.net.Socket;
        import java.net.UnknownHostException;
        import java.sql.Time;
        import javax.swing.JButton;
        import javax.swing.JFrame;
        import javax.swing.JPanel;
        import javax.swing.JTextArea;
        import javax.swing.JTextField;

public class ClientChatForm extends JFrame implements ActionListener {
    static Socket conn;
    JPanel panel;
    JTextField NewMsg;
    JTextArea ChatHistory;
    JButton Send;

    public ClientChatForm() throws UnknownHostException, IOException 
{
        panel = new JPanel();
        NewMsg = new JTextField();
        ChatHistory = new JTextArea();
        Send = new JButton("Send");
        this.setSize(500, 500);
        this.setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        panel.setLayout(null);
        this.add(panel);
        ChatHistory.setBounds(20, 20, 450, 360);
        panel.add(ChatHistory);
        NewMsg.setBounds(20, 400, 340, 30);
        panel.add(NewMsg);
        Send.setBounds(375, 400, 95, 30);
        panel.add(Send);
        56        Send.addActionListener(this);
        conn = new Socket(InetAddress.getLocalHost(), 2000);
/** for remote pc use ip address of server with function* InetAddress.getByName("Provide ip here")* ChatHistory.setText("Connected to Server");*/        ChatHistory.setText("Connected to Server");
        this.setTitle("Client");
        while (true) {
            try {
                DataInputStream dis = new DataInputStream(conn.getInputStream());
                String string = dis.readUTF();
                ChatHistory.setText(ChatHistory.getText() + '\n' + "Server:"                        + string);
            } catch (Exception e1) {
                ChatHistory.setText(ChatHistory.getText() + '\n'                        + "Message sending fail:Network Error");
                try {
                    Thread.sleep(3000);
                    System.exit(0);
                } catch (InterruptedException e) {
// TODO Auto-generated catch block                    e.printStackTrace();
                }
            }
        }
    }
    @Override    public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub        if ((e.getSource() == Send) && (NewMsg.getText() != "")) {
            ChatHistory.setText(ChatHistory.getText() + '\n' + "Me:"                    + NewMsg.getText());
            try {
                DataOutputStream dos = new DataOutputStream(
                        conn.getOutputStream());
                dos.writeUTF(NewMsg.getText());
            } catch (Exception e1) {
                ChatHistory.setText(ChatHistory.getText() + '\n'                        + "Message sending fail:Network Error");
                     try {
                    Thread.sleep(3000);
                    System.exit(0);
                } catch (InterruptedException e2) {
// TODO Auto-generated catch block                    e2.printStackTrace();
                }
            }
            NewMsg.setText("");
        }
    }
    public static void main(String[] args) throws UnknownHostException,
            IOException {
        ClientChatForm chatForm = new ClientChatForm();
    }
}


serverChatForm.java

        import java.awt.event.ActionEvent;
        import java.awt.event.ActionListener;
        import java.io.DataInputStream;
        import java.io.DataOutputStream;
        import java.io.IOException;
        import java.net.InetAddress;
        import java.net.ServerSocket;
        import java.net.Socket;
        import java.net.UnknownHostException;
        import javax.swing.JButton;
        import javax.swing.JFrame;
        import javax.swing.JPanel;
        import javax.swing.JTextArea;
        import javax.swing.JTextField;
public class serverChatform extends JFrame implements ActionListener {
    static ServerSocket server;
    static Socket conn;
    JPanel panel;
    JTextField NewMsg;
    JTextArea ChatHistory;
    JButton Send;
    DataInputStream dis;
    DataOutputStream dos;
    public serverChatform() throws UnknownHostException, IOException {
        panel = new JPanel();
        NewMsg = new JTextField();
        ChatHistory = new JTextArea();
        Send = new JButton("Send");
        this.setSize(500, 500);
        this.setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        panel.setLayout(null);
        this.add(panel);
        ChatHistory.setBounds(20, 20, 450, 360);
        panel.add(ChatHistory);
        NewMsg.setBounds(20, 400, 340, 30);
        panel.add(NewMsg);
        Send.setBounds(375, 400, 95, 30);
        panel.add(Send);
        this.setTitle("Server");
        Send.addActionListener(this);
        server = new ServerSocket(2000, 1, InetAddress.getLocalHost());
        ChatHistory.setText("Waiting for Client");
        conn = server.accept();
        ChatHistory.setText(ChatHistory.getText() + '\n' + "Client Found");
        while (true) {
            try {
                DataInputStream dis = new DataInputStream(conn.getInputStream());
                String string = dis.readUTF();
                ChatHistory.setText(ChatHistory.getText() + '\n' + "Client:"                        + string);
            } catch (Exception e1) {
                ChatHistory.setText(ChatHistory.getText() + '\n'                        + "Message sending fail:Network Error");
                try {
                    Thread.sleep(3000);
                    System.exit(0);
                } catch (InterruptedException e) {
// TODO Auto-generated catch block                    e.printStackTrace();
                }
            }
        }
    }
    @Override    public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub        if ((e.getSource() == Send) && (NewMsg.getText() != "")) {
            ChatHistory.setText(ChatHistory.getText() + '\n' + "ME:"                    + NewMsg.getText());
            try {
                DataOutputStream dos = new DataOutputStream(
                        conn.getOutputStream());
                dos.writeUTF(NewMsg.getText());
            } catch (Exception e1) {
                try {
                    Thread.sleep(3000);
                    System.exit(0);
                } catch (InterruptedException e2) {
// TODO Auto-generated catch block                    e2.printStackTrace();
                }
            }
            NewMsg.setText("");
        }
    }
    public static void main(String[] args) throws UnknownHostException,
            IOException {
        new serverChatform();
    }
}

Sunday, March 19, 2017

Write a Socket program in java for simple stand-alone chatting application.

Client.java

   import java.net.*;
   import java.io.*;
class Client
{
    public static void main(String[] args) throws Exception
    {
        Socket s=new Socket("localhost",500);
        System.out.println("Client send request to server!");
        DataOutputStream dos=new DataOutputStream(s.getOutputStream());
        DataInputStream dis=new DataInputStream(s.getInputStream());
        InputStreamReader ir=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(ir);
        while(true)
        {
            System.out.println("Client:");
            dos.writeUTF(br.readLine()); //send response to server.            System.out.println("Server:");
            System.out.println(dis.readUTF()); //Received from server.        }
    }
}

Server.java
 
       import java.net.*;
        import java.io.*;
class Server
{
    public static void main(String[] args) throws Exception
    {
        ServerSocket ss=new ServerSocket(500);
        System.out.println("Wait for client!");
        Socket s=ss.accept();
        System.out.println("Server accpted request");
        DataOutputStream dos=new DataOutputStream(s.getOutputStream());
        DataInputStream dis=new DataInputStream(s.getInputStream());
        53        InputStreamReader ir=new InputStreamReader(System.in);
        BufferedReader br=new BufferedReader(ir);
        while(true)
        {
            System.out.println("Client:");
            System.out.println(dis.readUTF()); //Receives info from client.            System.out.println("Server:");
            dos.writeUTF(br.readLine()); //sends response to client        }
    }
}

Create a JSP page to accept a number from an user and display it in words: Example: 123 – One Two Three. The output should be in red color.

NumberWord.html


<html>
<body>
<form method="get" action="NumberWord.jsp">
<fieldset>
<legend>Enter Any Number </legend>
<input type=text name=num><br><br>
</fieldset>
<div align=center>
<input type="submit" value="Display">
</div>
</form>
<body>
</html>
       

 NumberWord.jsp

<html>
<body>
<font color=red>
<%! int i,n;
        String s1;
        %>
<%
        s1=request.getParameter("num");
        n=s1.length();
        i=0;
        do        {
        char ch=s1.charAt(i);
        switch(ch)
        {
        case '0': out.println("Zero ");
        break;
        case '1': out.println("One ");
        break;
        case '2': out.println("Two ");
        break;
        51        case '3': out.println("Three ");
        break;
        case '4': out.println("Four ");
        break;
        case '5': out.println("Five ");
        break;
        case '6': out.println("Six ");
        break;
        case '7': out.println("Seven ");
        break;
        case '8': out.println("Eight ");
        break;
        case '9': out.println("Nine ");
        break;
        }
        i++;
        }
        while(i<n);
        %>
</font>
</body>
</html>