The Artima Developer Community
Sponsored Link

Java Answers Forum
Java Applet and IIS

1 reply on 1 page. Most recent reply: Aug 5, 2004 9:19 PM by Aing Roda

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Aing Roda

Posts: 9
Nickname: roda
Registered: Jul, 2004

Java Applet and IIS Posted: Aug 4, 2004 9:47 PM
Reply to this message Reply
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


Aing Roda

Posts: 9
Nickname: roda
Registered: Jul, 2004

Re: Java Applet and IIS Posted: Aug 5, 2004 9:19 PM
Reply to this message Reply
The problem has been fixed. It is working fine now.
I have corrected my code

From:

URL logfileURL1 = new URL(documentBase.getProtocol(), documentBase.getHost(), path + "/Total.log");

URL logfileURL2 = new URL(documentBase.getProtocol(), documentBase.getHost(), path + "/Record.log");


To:

URL logfileURL1 = new URL(documentBase.getProtocol(), documentBase.getHost(), 8080, path + "/Total.log");

URL logfileURL2 = new URL(documentBase.getProtocol(), documentBase.getHost(), 8080, path + "/Record.log");



===========
Roda

Flat View: This topic has 1 reply on 1 page
Topic: What is difference between an Application Server and Web Server Previous Topic   Next Topic Topic: SOAP Header Authentication!!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use