728x90 AdSpace

Latest News

Monday, 20 October 2014

Remote Invocation Method









AIM:
To write the Remote Invocation Method (RMI) program to find a factorial of a
number .
PROCEDURE:
1. Start the process.
2. To perform the RMI operation create Interface file, Implementation file, Server file and
Client file .
3. Perform the JAVA compilation for all files.
4. Perform the RMI compilation for the implementation file to create stub and skeleton by
using rmic command.
5. Start the RMI registry.
6. Run the server and client file separately.
7. Display the result.
8. Terminate the process.
PROGRAM:
CLIENT PROGRAM: import java.io.*; import java.rmi.*; public class client
{
public static void main(String args[])throws Exception
{
try
{
String s="rmi://"+args[0]+"/abc"; serverint f=(serverint)Naming.lookup(s); DataInputStream m=new DataInputStream(System.in); int n1=Integer.parseInt(m.readLine()); System.out.println("the factorial is"+f.fact(n1));
}
catch(Exception e)
{ System.out.println(e);
}
}
}
INTERFACE PROGRAM:
import java.rmi.*;
public interface serverint extends Remote
{
int fact(int n)throws Exception;
}
IMPLEMENTATION PROGRAM:


import java.rmi.*;
import java.rmi.server.*;
public class serverimpl extends UnicastRemoteObject implements serverint
{
public serverimpl()throws Exception
{
}
public int fact(int n)
{
int i,c=1;
for(i=1;i<=n;i++)
{
c=i*c;
}
return c;
}
}
SERVER PROGRAM: import java.net.*; import java.rmi.*; public class server
{
public static void main(String args[])
{
try
{
serverimpl m=new serverimpl(); Naming.rebind("abc",m);
}
catch(Exception e)
{ System.out.println("Exception"+e);
}
}
}
3.Servlet program with Student database connectivity
AIM:
To Write a Servlet Program with Database Connectivity for a Web Based

Application  such as Student’s Result.

ALGORITHM:

STEP 1: Start the process. STEP 2: Open Net Beans IDE.


STEP 3: Then click File Menu, Choose New Project. Select Java Web Folder from categories. Choose
Web Application in Project.,Click Next.

STEP 4: In New Application Dialog Box, type the Project Name. Click Next. Select

Apache Tomcat

6.0.026 Click Next & Finish.

To Create HTML Coding:

STEP 5: Right click on the Project Name.

STEP 6: Choose New, Select the HTML & type the Coding.

To Create Server Page:

STEP 7: Right click on Project Name.

STEP 8: Choose New, Select Servlet, New Servlet Dialog box appears.

STEP 9: Type the Class Name (The class name & the program name should be the same). STEP 10: Click Next & click Finish (Erase the predefined coding on screen & type the new coding for
application).

STEP 11: Right click on the documents & click to Save the document.

To Create Database Connectivity:

STEP 12: In Control Panel, select Administrator Tools, Click Data Source(ODBC). STEP 13: The ODBC Data Source Administrator Dialogbox appears.
STEP 14: Click Add, choose Oracle ODBC Driver, click Finish.

STEP 15: In Oracle 8 ODBC Driver setup dialogbox, type Data Source Name & click

Ok.

STEP 16: Verify the Data Source Name in ODBC Data Source Administrator Dialogbox. STEP 17: In Net Beans type the Coding.
To Run The Application:

STEP 18: Compile all the programs created for this application. STEP 19: Run the .html files to display Output.
STEP 20: To Run the particular file Right Click on the file & select Run. STEP 21: Stop the process.

  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Item Reviewed: Remote Invocation Method Description: Rating: 5 Reviewed By: Dinesh
Scroll to Top