This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 08 Nov 2004 10:24:15 am    Post subject:

It's absolutely impossibe to store a (text) file on the client's system using an applet, right? (and the same goes for storing files to the server, right?)

Is there a way around this using php? Like pass the info that's to be stored to a php script on the server?


Last edited by Guest on 08 Nov 2004 10:27:47 am; edited 1 time in total
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 08 Nov 2004 06:37:57 pm    Post subject:

I believe so for security reasons; however I could be extremely wrong.
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 09 Nov 2004 09:49:17 am    Post subject:

You are extremely right. On an applet it is not possible; on program it is.
Otherwise, it would be too easy to create a virus with applets...
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 09 Nov 2004 11:36:48 am    Post subject:

Java applications support it, but the thing is, I'm making an applet and it doesn't really need a save function, but I'd like it to so the users won't have to select all, and cut and paste all their work (which will be in 1 textfield) so I was wondering if it was possible to do it by passing on the info to a php script and have that save a temp file on the server and show an url to the user so (s)he can download their work.

*work*
save function -> pass text to php script
php script -> save on server -> show url to file
download, php script -> remove file from server

Problem is I don't know how to pass on the info to the PHP script.

I'm guessing I just need to open a connection to the php script with by creating an URL object like so..

url = new Url( "http://www.myhost.com/phpscriptfilename.php$=the_text_i_want_to_save" );

and then open a stream to it in order to retrieve the outputted url to the saved file on the server like so..

urlpage = url.openStream();

But that's just a guess.


Last edited by Guest on 09 Nov 2004 11:57:37 am; edited 1 time in total
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 09 Nov 2004 08:47:48 pm    Post subject:

You can save data to a server, although I've not gotten that far into Java yet so I wouldn't know how. (I'm sure you can because of all those Java RPGS online). I might be able to bring up some script later if you want it from my rotting 1000+pg book
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 10 Nov 2004 06:41:23 am    Post subject:

optimize wrote:
You can save data to a server, although I've not gotten that far into Java yet so I wouldn't know how. (I'm sure you can because of all those Java RPGS online).

That's a good point there.

Quote:
I might be able to bring up some script later if you want it from my rotting 1000+pg book
I'd appreciate it, but only if it's not too much effort, and you don't have to find an entire script, just the idea behind it/key functions, the book I have only handles file i/o in applications, not applets and it doesn't even handle random i/o, only streams.

But once I have an idea of how to do it or the key functions behind it I can figure it out, and then a first version of that tibasic interpreter I've mentioned might be posted some time soon.
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 10 Nov 2004 06:54:12 pm    Post subject:

I think the server thing is the way to go, perhaps the only way on an applet.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 11 Nov 2004 03:33:32 am    Post subject:

The question is, how?
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 11 Nov 2004 05:56:24 pm    Post subject:

Ugh... I'm not sure. I've seen games that do it (Runescape) but you'd have to find an open-source one. Flash is much easier to do that.
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 11 Nov 2004 06:47:55 pm    Post subject:

Ok I'll go look it up now and edit this post when I find it...

I might have found it. It deals with sending packets to the server, although I have no clue what this means I would believe its some way to "save" data...

You want more on it?


Last edited by Guest on 11 Nov 2004 06:52:21 pm; edited 1 time in total
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 11 Nov 2004 06:49:46 pm    Post subject:

Quote:
Ok I'll go look it up now and edit this post when I find it...

If you're looking for Runescape, give it up. No way that's open-source!
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 11 Nov 2004 06:54:28 pm    Post subject:

Quote:
If you're looking for Runescape, give it up. No way that's open-source!


That's not what I was looking for.

Quote:
I'd appreciate it, but only if it's not too much effort, and you don't have to find an entire script, just the idea behind it/key functions, the book I have only handles file i/o in applications, not applets and it doesn't even handle random i/o, only streams.


That's what I was looking for
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 12 Nov 2004 02:31:02 am    Post subject:

Oh, I thought you were looking for the Runescape source code, since I tlaked about it like one post before. Sorry.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 12 Nov 2004 06:38:24 am    Post subject:

optimize wrote:
You want more on it?

That.
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 12 Nov 2004 03:09:56 pm    Post subject:

Alright, this is a painfully long source code, here it goes...


Code:
import javax.swing.*;

public class Server extends JFrame {
     private JTextArea displayArea;
     private DatagramPacket sendPacket, receivePacket;
     private DatagramSocket socket;

     // set up GUI and DatagramSocket
     public Server()
     {

          super( "Server" );

          displayArea = new JTextArea();
          getContentPane().add( new JScrollPane( displayArea ),
               BorderLayout.CENTER );
          setsize( 400, 300 );
          setVisible( true );

          // create DatagramSocket for sending and receiving packets
          try {
               socket = new DatagramSocket( 5000 );
          }

          // process problems creating DatagramSocket
          catch( SocketException socketException ) {
               socketException.printStackTrace();
               System.exit( 1 );
          }

}     // end Server constructor

// wait for packets to arrive, then display data and echo
// packet to client
public void waitForPackets()
{
    // loop forever
    while ( true ) {

         // recieve packet, display contents, echo to client
         try {

              // set up packet
              byte data[] = new byte[ 100 ];
              recievePacket =
                   new DatagramPacket( data, data.length );
    
              // wait for packet
              socket.receive( recievePacket );

              // process packet
              displayPacket();

              // echo information from packet back to client
              sendPacketToClient ();
          }

          // process problems manipulating packet
          catch( IOException ioException ) {
               displayArea.append( ioException.toString() + "\n" );
               ioException.printStackTrace();
          }

     }     // end while

}     // end method waitForPackets

// display packet contents
private void displayPacket()
{
     displayArea.append( "\nPacket received:" +
          "\nFrom host: " + receivePacket.getAddress() +
          "\nHost port: " + receivePacket.getPort() +
          "\nContaining:\n\t +
          new String( receivePacket.getData(), 0,
               receivePacket.getLength() ) );
}

// echo packet to client
private void sendPacketToClient() throws IOException
{
     displayArea.append( "\n\nEcho data to client..." );

          // create packet to send
          sendPacket = new DatagramPacket( receivePacket.getData(),
               receivePacket.getLength(), receivePacket.getAddress(),
               receivePacket.getPort() );

          // send packet
          socket.send( sendPacket );

          displayArea.append( "Packet sent\n" );
          displayArea.setCaretPosition(
               displayArea.getText().length() );
}

// execute application
public static void main( String args[] )
{
     Server application = new Server();

     application.setDefaultCloseOperation(
          JFrame.EXIT_ON_CLOSE );

          application.waitForPackets();
     }

}     // end class Server


Might be a typo or two in there. I can't really answer any questions because I have pretty much no clue what all that stuff means but I might be able to find it in the page that describes what the program is doing.

Have fun Laughing
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 12 Nov 2004 10:44:02 pm    Post subject:

It has a few comments in it explaining what it's doing. I don't see why they would have a separate page for the comments or to say what it's doing.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 13 Nov 2004 05:49:55 am    Post subject:

optimize wrote:
Alright, this is a painfully long source code, here it goes...


Code:
<code>


Might be a typo or two in there. I can't really answer any questions because I have pretty much no clue what all that stuff means but I might be able to find it in the page that describes what the program is doing.

Have fun  Laughing

Awesome, thanks.

Quote:
It has a few comments in it explaining what it's doing. I don't see why they would have a separate page for the comments or to say what it's doing.
Books on programming usually describe it in more detail than just "// set up GUI and DatagramSocket" for an entire function.
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 13 Nov 2004 03:29:24 pm    Post subject:

Ooh... this was taken from a book!
It must have taken a while for him to type it up
Back to top
optimize


Advanced Newbie


Joined: 03 Aug 2004
Posts: 99

Posted: 13 Nov 2004 04:59:20 pm    Post subject:

Quote:
It must have taken a while for him to type it up

Had nothing better to do on a Friday afternoon
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement