We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

server-client concept

jfbe
jfbe asked
on
Medium Priority
288 Views
Last Modified: 2011-10-03
Hi

  Ina Gardner gave me this adress where I could ask   my questions. Well,
  let's say that although I've read 1 1/2 Java books and a    bit of JavaScript I'm still fustrated since I've not get    some important concepts. I don't know if you know were I    could find a general text that can answer to my questions   rather than the usual chapters in
  books that explain the Security Manager restrictions or   so...

  In 'Developing Professional Java Applets', page 124 they   gives this:

    myFile=new File("File.txt");
    ......
    ...
    File myDirectory=new File("...\\...");
    ...
    ...

  There's no URL specified in any operation related to such   classes in
  this chapter. In a chapter about socket, one could find   things like:
  outbound.writeBytes("GET /HTTP/1.0\r\n\r\n");

  Before I start to code extensivelly and buid a website, I   want to be
  sure if I have correctly some basical concepts:

 a)If I'm dealing with a provider (let's say my one ,VIR    communications)
   than there's no way to use classical databases in an       application. If my computer is shut down, a remote PC can
   access this site as long
   as a VIR server is available, but it is no longer my PC
   business once the applets are upload to this space       reserved on VIR server, right? So a database on my Hard    Drive is useless for my application
   normally except if I have enough space on a URL adress to    upload it in advance with FTP, right?  There's a couple     of examples with images in my book, but I'm not sure if     the princip can be really the same for databases like
   Oracle or so. I suppose that they have always an image
   of what you upload on their disk, no?

 b) I've not yet my website but it'll come soon.I think the     usual pattern is this one: the provider has a HTML wich
   is calling an applet that run  permanently ( the server).
   When someone access my URL and HTML scrip MY applet is    transfered to client's machine before to be interpreted.
   But since it is executed on client's machine, no data    
   can be write on my URL, they can just be read, right?    
   I've an example of a server applet in my book, but I    
   don't know how this one could run on a permanent base on    the server side (if I want to perform database operations    or so). How could I do if I want my own server applet to    run constently and respond rather than my provider's   applet???

  Thanks in advance

Comment
Watch Question

Commented:
Hello,

>there's no URL specified in any operation related
>to such classes in  chapter.
>In a chapter about socket, one could find things like:
>outbound.writeBytes("GET /HTTP/1.0\r\n\r\n");

In general Java is a full featured programming language as
C, C++, Smalltalk, Perl , Basic or whatever else are.
It must be precompiled and then it is interpreted by Java
virtual machine (JVM). [[You sure can omit precompiling by
replacing default ClassLoader by your own one that
run precompiler in suitable moments automatically. ]]

>Before I start to code extensivelly and buid a website,
>I want to be sure if I have correctly some basical concepts:

The package hierarchy is usually mapped into directory tree
on the one's disk. Java program is launched by starting
JVM while giving it name of some class and some command line
params. This class must
implement public static void main(String argv[]){} method
to get program started. Until this time it is much similar
to the good old  void main(char*....) in C {:)
Such a Java program can do anything with Files, Sockets, AWT
etc - no restrictions.

Another way to start up Java code is to make it as an Applet.
Your applet must subclass java.applet.Applet and instead
of static main() method in the previous case init() [[and some
other methods]] method will be called on automatically created instance of
your applet each time your applet is to be showed on someone's
page. You can make your applet to implement Runnable interface
and to start arbitrary computation with many threads with
several restrictions. You have no access to local files and
all you can do beeing applet is to connect using sockets
to URL you were downloaded from (== browsed).
These are general principles and it implies what can be done
with applets and what can not.

>a)If I'm dealing with a provider (let's say my one ,VIR
>communications)
>than there's no way to use classical databases in an
>application.
>If my computer is shut down, a remote PC can
> access this site as long
>as a VIR server is available, but it is no longer my PC
> business once the applets are upload to this space reserved on
> VIR server, right?
.. yes

 So a database on my Hard Drive is useless > >for my application   normally except if I have enough space on a >URL adress to upload it in advance with FTP, right? There's a
... exactly

>couple of examples with images in my book, but I'm not sure if >the princip can be really the same for databases like
>Oracle or so. I suppose that they have always an image
>of what you upload on their disk, no?
... I don't understand exactly

>b) I've not yet my website but it'll come soon.I think the usual
>  pattern is this one: the provider has a HTML wich
> is calling an applet that run permanently ( the server).
... You can have any number of various applets that
in their body connect via Socket to your database running
on WWW server or to your own Java server listening on some
socket running as a daemon {:) etc etc...

> When someone access my URL and HTML scrip MY applet is
>  transfered to client's machine before to be interpreted.
> But since it is executed on client's machine, no data
>  can be write on my URL, they can just be read, right?
... According to general rules you can only conect to your
mother WWW server via Socket. You can read/write data there.

> I've an example of a server applet in my book, but I
> don't know how this one could run on a permanent base on the
> server side (if I want to perform database operations or so).
 Just a sort of deamon running continuously... Written in Java
sure {:)

>How could I do if I want my own server applet to run constently >and  respond rather than my provider's applet???
... Applets are not designed for such kind of things, see
documention of java.applet.Applet -> start() stop() destroy()
methods.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.