Solved

application not applet; open new window separate from browser

Posted on 1998-01-09
6
291 Views
Last Modified: 2012-06-21
Hi,
  I'm writing a web client server app, some of which is in java.  A perl cgi script is called from the browser which forks a child process, and the child looks like this...

  else {
    $resnum--;
    $cmd = "java progressClient $resnum";
    exec $cmd;
    exit(0);
  }

The first part of the java application looks like this...

import java.awt.*;
import java.io.* ;
import java.net.* ;
class progressClient extends java.applet.Applet {
  public static void main(String[] args) {
    Frame frame = new Frame("Your inquiry is being processed");
    frame.setSize(300,200);
    frame.setVisible(true);
  // more code, mostly passing data back and forth thru a   //socket.

... but this code gets hung up and the new window never appears.  
I'd like to be able to open this new window to show the progress of a transaction which could take as long as 5 minutes, leaving the main browser window free for other activity while the customer waits.  The "extends
java.applet.Applet" was just a shot in the dark.  I really don't want to have to use an applet at all because so many people are still using browsers that won't run applets.  I would appreciate any suggestions.  I could open the new
window earlier, in the perl script, but after that, I wouldn't know how to manipulate the strings the program creates so that they'd show up in that
window.  Thank you!
0
Comment
Question by:zingbust
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1232101
Are you writing this on UNIX or PC plattforms?

Either way, I am assuming that you are calling the Perl script as a CGI. In either case, I'm not sure what you are trying to acomplish.

Do you want the frame to appear on the client or on the server?

If it on the the server, you will need to run the Java code in a new shell, if on the client, your code is completley shot and will not be able to display the frame on the client at all. For that, you would need to write an Applet that can launch the Script, synchronize with the script untill all data is available, transfer the data and then display itself.
0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1232102
If I understand what you've said above, you are trying to have a PERL cgi program on your server invoke a JAVA application (or applet) on client's browser to show that the operation is taking a long time.  If this is the case, your approach as show above is wrong.  First, a cgi-bin server program can't invoke Java on the client under any circumstances.  It could format a page to the output stream back to the browser which included an <APPLET> tag that the browser could (if it wanted to) load and run.  The only way it could process updates to the progress, however, would be to establish a network connection to another process on the server and receive status messages about the processing.  Even in that case, the applet would get clobbered if the user opened a new page or closed the browser.
0
 

Author Comment

by:zingbust
ID: 1232103
Thanks guys, and let me clarify a bit what I'm trying to do.
It's an information system that allows web users to submit from a web form a request for a transaction.  The transaction takes place by telephone.  A telephony server on my pc at home makes a phone call and delivers the transaction request to the business.  The business responds via touch-tone phone or voice message.  The telephony server relays the response back to the web user.  The web server is a unix platform.  The perl cgi script is what takes over after the user presses submit.  The forked process calls the java application I referred to in my question.  This application is run on the same unix machine as the perl script, it is NOT an applet run on the client's machine.  The java application makes a socket connection to the telephony application.  I would like a popup window to appear shortly after the user presses the submit button.  The java application is capable of keeping track of each phase of the transaction by receiving strings of text that come from the socket connection.  I would like to somehow be able to send these strings of text to the popup window..."Making connection to telephony server..."  "Dialing phone number of business..." "Party has answered the phone..."  "Transaction being processed, please wait..." "Transaction confirmed". The perl script's function is to return the html that the user would see in the main browser window.  Hopefully I could make it so that the main browser window is free and finished of it's duties so that the user could continue browsing while still having the popup window to look at to observe the progress of the transaction.  I realize the approach I was trying is no good, but surely there must be a way to accomplish this!?  Thanks for your input!!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:jpk041897
ID: 1232104
Any particular reason why you cant have teh Java app. running all the time and polling either a file or a socket to obtain the strings?
0
 

Author Comment

by:zingbust
ID: 1232105
To JPK: That is what I'm doing with the java application.  Problem is that I don't know how to send the strings to a new window, don't know exactly how or when I should try to open the new window for dynamic output.  Only examples I've seen open a with window.open(something.htm, etc, etc).  How do I get these strings into something.htm?  Can I do it without using an applet?
Should I find an ActiveX control that would do the job?
0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1232106
The new window could be a frame or a modeless dialog. If its a modeless dialog, its code is still active even when minimized or hidden by the parent frame.

There are several mechanisms you could then use to determine te contents of the transfered strings. For instance, you could use a flag in a static class, the existance of a file either on disk or on a remote server, etc.

The main trick is to have a permanently open window that hides itself when not needed. If you need more than one window, you could create a dialog (or frame) instance for each client.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to use external config file with Spring MVC 4 61
groupSum6 challenge 6 35
word0 challenge 3 58
Python Assistance 7 35
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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:

757 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

24 Experts available now in Live!

Get 1:1 Help Now