Java Serialized objects

  • Thread starter Chandrashekar Tippur
  • Start date
C

Chandrashekar Tippur

All,

I have a serialized object which reads and writes to a file. While it
reads, it fills up its attributes. When I try to run this on a
astandalone machine, it works fine but when I try with client server
(Via the browser) it is coming up with AcccessControlException and the
exception looks like the program is trying to write in the client
rather than the server. I want both read and write from the file to
happen at the server.
Please let me know where I am going wrong.

Shekar
 
C

Christophe Vanfleteren

Chandrashekar said:
All,

I have a serialized object which reads and writes to a file. While it
reads, it fills up its attributes. When I try to run this on a
astandalone machine, it works fine but when I try with client server
(Via the browser) it is coming up with AcccessControlException and the
exception looks like the program is trying to write in the client
rather than the server. I want both read and write from the file to
happen at the server.
Please let me know where I am going wrong.

Shekar

Any File object works on the *local* filesystem. So for an applet, this is
the client the applet is running on.

You can read from a file on the server as easy as from a local one using an
URL, but writing to it is not that simple. You'll have to use something
like RMI, HTTP Post or FTP.
 
A

Andrew Thompson

I have a serialized object which reads and writes to a file. While it
reads, it fills up its attributes. When I try to run this on a
astandalone machine, it works fine but when I try with client server
(Via the browser)

An _Applet_?
...it is coming up with AcccessControlException

Ahh yep. Sounds like an applet.

They need to be jar'd and signed in
order to work through a browser (or
you can mess with policy files - which
is hardly practical for an average
web-surfer)
...and the
exception looks like the program is trying to write in the client
rather than the server.

Oh wait, you want to write on the _server_..

That can sometimes by done by opening
an URL back to the server of origin,
but I have never seen code that makes
it work.

Another way is to send data back to a
servlet or such that writes the file for you.

Hopefully one of the 'applet upload'
wizards will come along and outline
all the myriad and arcane options..
..I want both read and write from the file to
happen at the server.

Reading from the server is easy,
it is the writing that is tricky.
Please let me know where I am going wrong.

Line 42, column 21. Change the ':' to a ';'. [ ;-) ]
 
R

Roedy Green

I want both read and write from the file to
happen at the server.
Please let me know where I am going wrong.

You are asking us to be mindreaders to guess what is wrong with your
code without seeing it. However, since we have all made many mistakes
in past, we are getting pretty good at it.

See http://mindprod.com/jgloss/fileio.html

I suspect you are using the File methods to write to the local hard
disk. Applets are not permitted to do that without being signed.

THERE IS NO WAY TO DIRECTLY WRITE FILES ON THE SERVER. THERE IS NO
REMOTE FILE I/O IN JAVA. This is not DecNet.

So you have to kludge something up. E.g. an HTTP Get/Put or a raw
socket write or RMI. You need corresponding code on the server to
receive the transmission and store it on disk.

For your options see http://mindprod.com/jgloss/remotefileaccess.html
 
R

Roedy Green

That can sometimes by done by opening
an URL back to the server of origin,
but I have never seen code that makes
it work.

Read but not write. You can do a post, but few servers support that
because it is such a security hole.
 
T

Tony Morris

Roedy Green said:
Read but not write. You can do a post, but few servers support that
because it is such a security hole.

This all assumes that the URL is using HTTP for the transport mechanism.
Using some other transport protocol, submitting data for write is trivial.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 
R

Roedy Green

This all assumes that the URL is using HTTP for the transport mechanism.
Using some other transport protocol, submitting data for write is trivial.

But that still does not give you access to the file system of the
server. All you can do is talk to some program on the server and
persuade it to use the file system on your behalf.


It is not like the way for example you can use the local file access
methods in Java in Windows to get at files in a shared directory in
another machine on the LAN, just as if they were local.

There are schemes for doing that across the net, e.g. Novell, but Java
does not support them in a platform-independent way. There HAS to be a
much more elaborate security system that you use for intranet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top