Sandeep Ghosh

Greenhorn
+ Follow
since Mar 10, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sandeep Ghosh

Hi Adam,
Could I have the link of that Servlet forum
Thanks in adv
Sandeep

------------------
23 years ago
Hi Ragu and Valentin
Thanks a lot for help,but I still I have one question left.Why we use true in ObjectOutputStream constructor
Sandeep

Hi All
I have created a class student whose 2 objects will be serialized to MyStudent.txt file .Problem is when I am trying to read both record it is giving java.io.StreamCorruptedException.
Can any body help with the solution
Thank in adv
Sandeep
import java.io.*;
class student implements Serializable
{
String name,address;
int age,marks;
public void getdata(String n,String a,int age1,int m)
{
name=n;
address=a;
age=age1;
marks=m;
}
public String getname()
{
return name;
}
public String getaddress()
{
return address;
}
public int getage()
{
return age;
}
public int getmarks()
{
return marks;
}

}

class writerecords
{

public void writerecord(student s)
{
try{
FileOutputStream f=new FileOutputStream("Student.txt",true);
ObjectOutputStream o=new ObjectOutputStream(f);
o.writeObject(s);
f.close();
o.close();
}catch(Exception e){System.out.println("There is a error in writerecord");}
}
public void readrecord()
{
try{
student s;
FileInputStream f=new FileInputStream("Student.txt");
ObjectInputStream o=new ObjectInputStream(f);
s=(student)o.readObject();
System.out.println(s.getname()+"\t"+s.getaddress()+"\n");
//read the second record
s=(student)o.readObject();
System.out.println(s.getname()+"\t"+s.getaddress()+"\n");\
o.close
}
catch(EOFException e)
{
System.out.println("End of File Reached");
System.exit(1);
}
catch(Exception ef)
{
System.out.println("Error");
}
}
public static void main(String args[])
{

student stud=new student();
stud.getdata("Mr x","India",23,56);
writerecords w=new writerecords();
w.writerecord(stud);
//writing the second record
stud.getdata("Mr Y","Bangladesh",46,54);
w.writerecord(stud);
w.readrecord();

}
}
Exception
java.io.StreamCorruptedException: Type code out of range, is -84
at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1280)
at java.io.ObjectInputStream.refill(ObjectInputStream.java:1401)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:273)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
at writerecords.readrecord(writerecords.java:56)
at writerecords.main(writerecords.java:80)
Hi ,
In my application I need to create a report.Does Java provides reporting tool like Crystel Report of Visual Basic.
Thanks in adv
Sandeep
23 years ago
Hi all,
I am new to RMI. I have compiled the codes posted by Aj Manch in win2000.
which are as follows
//remote interface
package compute;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Compute extends Remote
{
Object executeTask() throws RemoteException;
}
//server implementation
package engine;
import java.rmi.*;
import java.rmi.server.*;
import compute.*;
public class ComputeEngine extends UnicastRemoteObject implements Compute
{
public ComputeEngine() throws RemoteException
{
super();
}
public Object executeTask()
{
return "Invoked executeTask.";
}
public static void main(String[] args)
{
if (System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
String name = "//localhost/Compute";
try {
Compute engine = new ComputeEngine();
Naming.rebind(name, engine);
System.out.println("ComputeEngine bound");
} catch (Exception e)
{
System.err.println("ComputeEngine exception: " + e.getMessage()); e.printStackTrace();
}
}
}
//policy file
grant {
permission java.security.AllPermission;
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535","connect,accept";
permission java.net.SocketPermission "*:80", "connect";
};
In addition to this I have written the client part as follows.
import compute.Compute;
import java.applet.Applet;
import java.awt.Graphics;
import java.rmi.*;
import java.rmi.server.*;
public class HelloApplet extends Applet{
String message="blank";
Compute obj= null;
public void init(){
try{
obj=(Compute)Naming.lookup("//192.168.25.1/Compute");
message =(String)obj.executeTask();
}
catch (Exception e){
System.out.println("HelloApplet exception:"+ e.getMessage());
e.printStackTrace();
}
}
public void paint(Graphics g){
g.drawString(message, 25, 50);
}
}
In the server machine IIS server is running and I have added a virtual directory with Alias "Compute".When I am running the server and client from same machine it is working but when I am taking client to different machine it is giving following error
java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.25.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:195)
at java.security.AccessController.checkPermission(AccessController.java, Compiled Code)
at java.lang.SecurityManager.checkPermission(SecurityManager.java, Compiled Code)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1021)
at java.net.Socket.<init>(Socket.java:258)
at java.net.Socket.<init>(Socket.java:98)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:29)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:124)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:497)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:194)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:178)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:89)
at HelloApplet.init(HelloApplet.java:26)
at sun.applet.AppletPanel.run(AppletPanel.java:333)
at java.lang.Thread.run(Thread.java:479)

could anybody give me the solution to the above problem.'
Thanks in advance
Sandeep

------------------
23 years ago
Thanks a lot William and Zoe.I was looking for just this kind of suggestion.
Sandeep
------------------
23 years ago
Hi,
I am new this part of the JavaRanch forum.I want to install Java Servlet Development Kit(JSDK) but don't know from where I could download .I have JDK1.2 already installed .Can anybody guide me in this matter .I am sorry if this kind of mail has already been posted in this forum.
Thanks in advance
Sandeep

------------------
23 years ago
Hi,
I am new this part of the JavaRanch forum.I want to install Java Servlet Development Kit(JSDK) but don't know from where I could download .I have JDK1.2 already installed .Can anybody guide me in this matter .I am sorry if this kind of mail has already been posted in this forum.
Thanks in advance
Sandeep

------------------
23 years ago
Hi,
As we know there are lots of decompilers available in market which can show source code from .class file.Isn't there is any mechanism which can stop others from reading source code
Thanks in advance.
Sandeep

------------------
23 years ago
Thanks Junilu,Ghanashyam now my doubt is cleared
Sandeep
Hi
I am having some problem in understanding the concept of volatile keyword in Java .In Khalid's book it has been mentioned that this variable's value can change asynchronously .The compiler should not attempt to optimize it. What it actually means.Thanks in advance
Sandeep

------------------
Hi,
Can anybody tell me the link from where I could get the Jane's notes or could anybody mail me the notes at sandeepghosh@hotmail.com
Thanks
with regards,
Sandeep
------------------
I am confused with usage of unicode characters set in Java.Can anybody give me the details regarding this concept.
With regards
Sandeep
------------------
Hi all,
Thanks for all information.I was looking for these information only.I visited www.enthuware.com,they have different section for Indians.We could buy their software for Rs 500 instead of Rs 1000,but they will not give any Guarantee.What Guarantee they are talking about??
Sandeep
------------------