Java Blog

 
 
 
// revsent.idl

module revsent_val
{
  interface revsent
  {
    string getstr(in string a);
  };
};


// revsent_client.java

import revsent_val.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import java.io.*;
import java.lang.*;
public class revsent_client
{
    static revsent revsentimpl;
    public static void main(String args[])
    {
      try
      {

        String result_str,tempstr;
        ORB orb=ORB.init(args,null);
        org.omg.CORBA.Object objref=orb.resolve_initial_references(\"NameService\");

        NamingContextExt ncref=NamingContextExtHelper.narrow(objref);

        String pathname=\"revsent\";
        revsentimpl=revsentHelper.narrow(ncref.resolve_str(pathname));

        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

        System.out.println(\"Enter string you want to send to server : \");
        tempstr=in.readLine();
        StringBuffer string1=new StringBuffer(tempstr);

        System.out.println(\"String sent to server : \"+string1);

        result_str=revsentimpl.getstr(string1.toString());

        System.out.println(\"String recvd from server is as below:\");
        System.out.println(result_str);

      }
      catch(Exception e)
      {
         System.out.println(e);
      }
    }

}


// revsent_server.java

import revsent_val.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import java.lang.*;
import java.util.*;

class serverimpl extends revsentPOA
{
   private ORB orb;
   public void setorb(ORB orb_val)
   {
      orb=orb_val;
   }

   public String getstr(String str1)
   {
     StringBuffer strb1=new StringBuffer(str1);
     strb1.insert(0,\' \');
     String ans_str=\"\";
     int len=strb1.length()-1;
     int j=0;
     System.out.println(\"length:\"+len);

     for(int i=len;i>=0;i--)
     {
       if(strb1.charAt(i)==\' \')
         {
          ans_str+=strb1.substring(i+1,len+1);
          j=i-1;
          break;
        }
     }

     for(int i=j;i>=0;i--)
     {
       if(strb1.charAt(i)==\' \' || i==0)
         {
          ans_str+=strb1.substring(i,j+1);
          j=i-1;
          }
     }

     return(ans_str);
   }
}
public class revsent_server
{
   public static void main(String args[])
   {
     try
     {
         ORB orb=ORB.init(args,null);

         org.omg.CORBA.Object objref1=orb.resolve_initial_references(\"RootPOA\");
         POA rootpoa=POAHelper.narrow(objref1);
         rootpoa.the_POAManager().activate();

         serverimpl serverobj=new serverimpl();
         serverobj.setorb(orb);
         org.omg.CORBA.Object objref2=rootpoa.servant_to_reference(serverobj);
         revsent href=revsentHelper.narrow(objref2);

         org.omg.CORBA.Object objref3= orb.resolve_initial_references(\"NameService\");
         NamingContextExt ncref=NamingContextExtHelper.narrow(objref3);
         String pathname=\"revsent\";
         NameComponent path[]=ncref.to_name(pathname);
         ncref.rebind(path,href);

         System.out.println(\"server ready and waiting...\");

         orb.run();

     }
     catch(Exception e)
     {
       System.out.println(e);
     }
   }

}


// OUTPUT

E:\\DIPI1\\corba prgs\\revsent>java revsent_client -ORBInitialPort 1050 -ORBInitialHost a

Enter string you want to send to server :
hi this is the test of reversing a string by its words

String sent to server : hi this is the test of reversing a string by its words

String recvd from server is as below:
words its by string a reversing of test the is this hi

    Related Post:
  1. An applet program that displays random dot

  2. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  3. Program to show the use of For Loop

  4. Program to read the price of an item in decimal form (like 75.95) and print the output in paise (like 7595 paise).

  5. Program of creating a file using text fields in windows

  6. Program of concatenating and Buffering files

  7. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  8. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  9. Program that accepts a shopping list of five items from the command line and stores them in vector

  10. Program of writing Bytes to a File

  11. Program for Thread Priority

  12. Program to declare, initialize and print an array of characters

  13. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  14. Define an array of ten String elements each containing an arbitrary string of the form “month/day/year”

  15. Program using Switch case to compute the net amount to be paid by a customer

  16. Program to reverse the number eg given no : - 12345, output want :- 54321

  17. Program to show an example of creating a class and using its object

  18. Program to read the ballots and count the votes cast for each candidate using an array variable count

  19. Socket program of HTTP Server

  20. An applet program to display Vertical Color Bar