Solved

Starting application from applet

Posted on 1997-07-22
3
253 Views
Last Modified: 2012-06-27
Hi,
  Is there any way to start an application (on server, of   course) from an applet. I don't want to use RMI. I want
  my application do perform some tranactions based on   applet's input.
  input.
 
0
Comment
Question by:brat072297
3 Comments
 

Expert Comment

by:musser
ID: 1223615
You would like to start an application on the same
host as the HTTP Server so that you can have it perform
transactions based on the applets input.
Do you require a response from this application?

It sounds like you could do this using a CGI invokation of
the application. Is this what you had in mind?  You could use
servlets.

Another approach would be to create an application server which runs on the HTTP host and listens on a dedicated port.  The
applet opens a socket on this port and sends a message to the
app server which indicates which application to run.  The application server spawns a process to run the given
application.  Results can be returned a variety of ways.


0
 

Author Comment

by:brat072297
ID: 1223616
I was thinking of CGI, too.
However I don't have any idea how to pass the reslult (vector of
strings) back to the applet (it has to be passed to the applet, because I want it to communicate with JavaScript).
0
 
LVL 1

Accepted Solution

by:
blacklion earned 150 total points
ID: 1223617
You can do it with CGI, servlets and others by connecting to the server from your applet as following:

Vector strings = null;
try
{
  InputStream in = new URL("http://someserver/cgi-bin/some.cgi").
    openStream();
  DataInputStream din = new DataInputStream(in);  
  for (String line = is.readLine(); line != null;)
    {
      strings.addElement (line);
    }
  din.close();
  in.close();
}
catch(MalformedURLException e)
{
  <bad URL>
  strings = null;
}
catch (IOException e)
{
  <error in I/O>
  strings = null;
}

if (strings != null)
  <strings contains output from the server>


You can also use URL.openConnection().getInputStream() and so on.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now