Solved

One Applet calling another

Posted on 1998-10-02
3
812 Views
Last Modified: 2008-03-04
1. I want to activate one applet, by pushing a bottun in another applet.
2. I want to activate a CGI by pressing a button in an applet.
How do I do it??
0
Comment
Question by:osnat
  • 2
3 Comments
 

Author Comment

by:osnat
Comment Utility
Edited text of question
0
 
LVL 2

Accepted Solution

by:
shchuka earned 20 total points
Comment Utility
What do you mean by "activate one applet by pushing a button in another applet"?  Do you want to load a page with the second applet when you push a button on the first applet?  In this case, you need to use this syntax:

this.getAppletContext().showDocument("url")

where url is the url of the page with the second applet.

As to CGI, there are two ways you can do it.  If it's a GET cgi, you can use the same syntax:

this.getAppletContext().showDocument("cgi-url?param1=val1&param2=val2...")

param=val strings should be url-encoded (e.g. " " changed into "+", and so on).  If you want to activate the POST cgi, you need to establish connection to the server through sockets and send the request in the form:

   POST /path/cgi-name HTTP/1.0
   Connection: Keep-Alive
   User-Agent: Mozilla/4.05 [en] (Win95; I)
   Host: www.cmscience.com
   Content-type: x-form-urlencoded
   Content-length: <length of your parameters string>
   Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
   Accept-Language: ru
   Accept-Charset: iso-8859-1,*,utf-8

   param1=val1&param2=val2...  (this is your parameter string).

Each line should end with "\r\n", not simply "\n".  The whole thing should be followed by "\r\n\r\n".  The problem with this method is that you're going to get back the html text output by the cgi program/script - you'll need to think of a way to display this html back into the browser.

Hope this helps,
-Aleks.
0
 

Author Comment

by:osnat
Comment Utility
Thank u for your answer!
I still have a problem (I'm just a beginner in Java...)
I want to activate an applet, that it's location is the same as the applet that activaed it: on the same directory, on my computer. As the matter affect: It's like trying to execute a program. All I have is the applet name and it's class file. And I want that by a press of a button, this class file will be executed!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 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

15 Experts available now in Live!

Get 1:1 Help Now