Aing Roda
Posts: 9
Nickname: roda
Registered: Jul, 2004
Java Applet and IIS
Posted: Aug 4, 2004 9:47 PM
Advertisement
Hi, I have a java applet code as below. My code is working fine with IIS on standard http port, 80. But I have another service running on port 80. So, I use port 8080 for my IIS instead. But the code doesn't work with port 8080. Anyone can correct my code to make it work with port 8080? I don't know how to correct it. I am new to java. import java.io.*; import java.net.*; import java.awt.*; import java.applet.Applet; public class CallsGraph extends Applet{ public void paint(Graphics g){ setBackground(Color.white); String ncalls = ""; int minute = 0; String hour = ""; int count = 100; int inthour; int j = 0; int y1 = 0; int y2 = 0; int y = 0; try{ URL documentBase = getDocumentBase(); String path = documentBase.getPath(); path = path.substring(0, path.lastIndexOf("/")); URL logfileURL1 = new URL(documentBase.getProtocol(), documentBase.getHost(), path + "/Total.log"); URLConnection connection1 = logfileURL1.openConnection(); InputStreamReader isr1 = new InputStreamReader(connection1.getInputStream()); BufferedReader br1 = new BufferedReader(isr1); String lineRead1 = ""; g.setColor(Color.green); while ((lineRead1 = br1.readLine()) != null){ ncalls = lineRead1.substring(7, 10); y = Integer.parseInt(ncalls); g.drawLine(count, 320-y, count, 320); count++; } count = 100; URL logfileURL2 = new URL(documentBase.getProtocol(), documentBase.getHost(), path + "/Record.log"); URLConnection connection2 = logfileURL2.openConnection(); InputStreamReader isr2 = new InputStreamReader(connection2.getInputStream()); BufferedReader br2 = new BufferedReader(isr2); String lineRead2 = ""; while ((lineRead2 = br2.readLine()) != null){ ncalls = lineRead2.substring(7, 10); minute = Integer.parseInt(lineRead2.substring(3, 5)); if (minute == 0) { hour = lineRead2.substring(0, 2); inthour = Integer.parseInt(hour); if (inthour%2 == 0) { hour = Integer.toString(inthour); g.setColor(Color.black); g.drawString(hour, count-3, 340); for (int i = 20; i <= 320; i+=5) { g.drawString(".", count, i); } } } y = Integer.parseInt(ncalls); if (count==100) { y1 = y; } else if (y2 > y1) { if ((y > y1) && (y > y2) ) { y1 = y2; } else if ((y > y1) && (y < y2)) { y1 = y; } } else if (y1 > y2) { if ((y > y2) && (y < y1)) { y1 = y; } else if ((y < y1) && (y < y2)) { y1 = y2; } } g.setColor(Color.red); g.drawLine(count, 320-y, count, 320-y1); y2 = y1; y1 = y; count++; } g.setColor(Color.black); for (int i=20; i<320; i+=20){ ncalls = Integer.toString(i); g.drawString(ncalls,70, 322-i); g.drawString(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .", 100, 320-i); } g.drawLine(100, 20, 100, 320); g.drawLine(100, 320, 485, 320); g.drawString(">", 485, 325); g.setColor(Color.green); g.drawString("All Operators",585, 100); g.setColor(Color.red); g.drawString("Mobitel (012)", 585, 130); }catch(MalformedURLException murle){ g.drawString(murle.getMessage(), 100, 100); getAppletContext().showStatus(murle.getMessage()); }catch(IOException ioe){ g.drawString(ioe.getMessage(), 100, 100); getAppletContext().showStatus(ioe.getMessage()); } } }
Thanks in advance. ============================= Roda