Java Serialized objects

Discussion in 'Java' started by Chandrashekar Tippur, Apr 25, 2004.

  1. 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
    Chandrashekar Tippur, Apr 25, 2004
    #1
    1. Advertising

  2. Chandrashekar Tippur wrote:

    > 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.

    --
    Kind regards,
    Christophe Vanfleteren
    Christophe Vanfleteren, Apr 25, 2004
    #2
    1. Advertising

  3. On 25 Apr 2004 00:37:02 -0700, Chandrashekar Tippur wrote:

    > 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 ';'. [ ;-) ]

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
    Andrew Thompson, Apr 25, 2004
    #3
  4. Chandrashekar Tippur

    Roedy Green Guest

    On 25 Apr 2004 00:37:02 -0700, (Chandrashekar Tippur)
    wrote or quoted :

    > 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


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Apr 25, 2004
    #4
  5. Chandrashekar Tippur

    Roedy Green Guest

    On Sun, 25 Apr 2004 07:51:54 GMT, Andrew Thompson
    <> wrote or quoted :

    >
    >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.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Apr 25, 2004
    #5
  6. Chandrashekar Tippur

    Tony Morris Guest

    "Roedy Green" <> wrote in message
    news:...
    > On Sun, 25 Apr 2004 07:51:54 GMT, Andrew Thompson
    > <> wrote or quoted :
    >
    > >
    > >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.
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


    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)
    Tony Morris, Apr 25, 2004
    #6
  7. Chandrashekar Tippur

    Roedy Green Guest

    On Sun, 25 Apr 2004 10:51:10 GMT, "Tony Morris" <>
    wrote or quoted :

    >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.



    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Apr 26, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rohit
    Replies:
    2
    Views:
    505
    rohit
    May 2, 2005
  2. Pep
    Replies:
    1
    Views:
    331
  3. Will
    Replies:
    3
    Views:
    10,462
  4. Dave Brown
    Replies:
    7
    Views:
    566
    Roedy Green
    Mar 10, 2006
  5. Jason Mobarak
    Replies:
    1
    Views:
    251
    =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?=
    Jul 3, 2004
Loading...

Share This Page