This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
hi I am trying to access an applet from a servlet .Everytime i run the servlet , it just shows a blank image .The applet contains a pie chart and is compiling well.Can someone tell where i am going wrong .....???servlet resides on iplanet and applet on a local machine. Applet CODE : ------------------------------------------- import java.applet.*; import java.awt.*; import java.awt.event.*; public class PieChart extends Applet implements ActionListener { int red, blue, green, yellow; Label instrutions= new Label("Enter 4 dollar amounts for your investment portfolio and press ENTER in box 4. "); Label highRisk = new Label("High Risk"); Label mediumRisk = new Label("Medium Risk"); Label lowRisk = new Label("Low Risk"); Label noRisk = new Label("No Risk"); TextField txtHighRisk = new TextField(" ", 10); TextField txtMediumRisk = new TextField(" ", 10); TextField txtLowRisk = new TextField(" ", 10); TextField txtNoRisk = new TextField(" ", 10); static private int CIRCLE= 360; public void init() { add(instrutions); add(highRisk); add(txtHighRisk); add(mediumRisk); add(txtMediumRisk); add(lowRisk); add(txtLowRisk); add(noRisk); add(txtNoRisk); txtNoRisk.addActionListener(this); } public void actionPerformed(ActionEvent thisEvent) {
int intHighRisk = Integer.parseInt(txtHighRisk.getText ()); int intMediumRisk = Integer.parseInt (txtMediumRisk.getText()); int intLowRisk = Integer.parseInt(txtLowRisk.getText()); int intNoRisk = Integer.parseInt(txtNoRisk.getText()); red = intHighRisk * CIRCLE; blue = intMediumRisk * CIRCLE; green = intLowRisk * CIRCLE; yellow = intNoRisk * CIRCLE; repaint(); }
Your code looks fine, the problems exists on where you are hosting the components. The servlet is looking for your applet off of ITS root file system. It doesn't know that /home is on a different machine. You need to make the path to the applet the full URL. In addtion, the servlet will not be able to access the applet on a file system. The applet will need to be hosted on a webserver so the applet can find it.
Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Just try to use fully qualified class name of the applet as the value of code attribute: CODE="packagename.classname.class". Also applet class file should be placed within web application, e.g. web application name is 'test', then you access servlet via http://hostname :port/test/servlet/Servletname.class Applet class file should be placed in test/packagename/ folder within your web server. In this case you dont have to mess with CODEBASE attribute value and can leave it to be "." [ August 11, 2003: Message edited by: Andrey Orekhov ]