Solved

Starting application from applet

Posted on 1997-07-22
3
265 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 80
Free Alternative to JIRA 4 91
eclipse formatting 6 74
why cannot we forward request once the response is committed 2 34
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

863 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

20 Experts available now in Live!

Get 1:1 Help Now