home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
samples.z
/
IURL_Poller.wxc
< prev
next >
Wrap
Text File
|
1997-01-28
|
7KB
|
241 lines
Save Format v2.0(1)
@begin ClassFile "IURL_Poller"
Exported 0;
Abstract 0;
Interface 0;
PackageName "";
Language "Java";
@begin UserFunction "IURL_Poller()"
Compiler 1;
GencodeSrcLine 13;
FunctionName "IURL_Poller::IURL_Poller()";
@end;
@begin UserFunction "main(String args[])"
Compiler 1;
GencodeFunction 1;
GencodeSrcLine 17;
FunctionName "IURL_Poller::main(String args[])";
@end;
@begin UserFunction "CreateMainForm()"
Compiler 1;
GencodeFunction 1;
GencodeSrcLine 24;
FunctionName "IURL_Poller::CreateMainForm()";
@end;
@begin UserFunction "StartApp(String args[])"
Compiler 1;
GencodeSrcLine 27;
FunctionName "IURL_Poller::StartApp(String args[])";
@end;
@begin UserFunction "RunApp(String args[])"
Compiler 1;
GencodeSrcLine 35;
FunctionName "IURL_Poller::RunApp(String args[])";
@end;
@begin UserFunction "EndApp(String args[])"
Compiler 1;
GencodeSrcLine 141;
FunctionName "IURL_Poller::EndApp(String args[])";
@end;
@begin HPPPrefixBlock
@begin-code HPPPrefix
// add your custom import statements here
import java.io.*;
import java.net.*;
import java.util.*;
@end-code;
GencodeSrcLine 6;
@end;
@begin ClassContentsBlock
@begin-code ClassContents
// add your data members here
WebConnection server;
@end-code;
GencodeSrcLine 144;
@end;
@begin-code BaseClassList
extends Object
@end-code;
@begin-code GeneratedClassContents
@end-code;
@begin-code Code "IURL_Poller::IURL_Poller()"
public @CLASSNAME@()
{
super();
}
@end-code;
@begin-code Code "IURL_Poller::main(String args[])"
public static void main(String args[])
{
@@CLASSNAME@ app = new @CLASSNAME@();
app.StartApp(args);
app.RunApp(args);
app.EndApp(args);
}
@end-code;
@begin-code Code "IURL_Poller::CreateMainForm()"
public void CreateMainForm()
{
}
@end-code;
@begin-code Code "IURL_Poller::StartApp(String args[])"
public void StartApp(String args[])
{
server = new WebConnection(args);
if (! server.getConnected() ) {
System.err.println("Connection to Server failed");
System.exit(2);
}
}
@end-code;
@begin-code Code "IURL_Poller::RunApp(String args[])"
public void RunApp(String args[])
{
//CreateMainForm();
try {
// Print out the headers and titles
server.setResponseHeader( "Content-Type", "text/html" );
server.writeln( "<CENTER><H1>Java ISAPI / NSAPI URL Poller Sample</H1></CENTER>" );
server.writeln( "<P>\n<BR>\n<HR>\n<BR>" );
URLList urlList = new URLList();
// Get the URL to be added, as well as the time interval for polling
String URLString = null;
String pollInterval = null;
if( server.getIsPostMethod() ) {
URLString = server.getFormVariable( "url" );
pollInterval = server.getFormVariable( "pollInterval" );
} else {
URLString = server.getQueryVariable( "url" );
pollInterval = server.getQueryVariable( "pollInterval" );
}
// Get the polling interval; if none is specified, used the default
long pollTime = 0;
if( pollInterval != null ) {
pollTime = ( new Long( pollInterval ) ).longValue();
pollTime = pollTime * 60 * 1000;
} else {
pollTime = urlList.getPollInterval();
}
pollTime = ( pollTime / 1000 ) / 60;
server.write( "<P>This server will poll the list of URLs every " );
server.write( Long.toString( pollTime ) );
server.writeln( " minute(s)." );
server.write( "<P>Here is a current list of the URLs stored by the server" );
server.writeln( " and their status since the last poll." );
server.writeln( "<P>\n<BR>" );
// If a URL was specified to be added, add it to the list
if( URLString != null ) {
urlList.addURL( URLString );
}
urlList.startPolling();
// Print out a list of URLs currently stored by the server, as well
// as their status since the last poll
server.writeln( "<CENTER><TABLE BORDER=4 BGCOLOR=WHITE>" );
server.writeln( "<TR>" );
server.writeln( "<TH>URL</TH>" );
server.writeln( "<TH>Status</TH>" );
server.writeln( "</TR>" );
for( Enumeration e = urlList.getURLs(); e.hasMoreElements(); ) {
URLStatus oneItem = ( URLStatus ) e.nextElement();
URL url = oneItem.getURL();
int status = oneItem.getStatus();
server.writeln( "<TR>" );
// Print out the URL and make a link to it if it's new
server.write( "<TD>" );
if( status == URLStatus.NEW ) {
server.write( "<A HREF=\"" );
server.write( url.toString() );
server.write( "\">" );
server.write( url.toString() );
server.write( "</A>" );
} else {
server.write( url.toString() );
}
server.writeln( "</TD>" );
// Print out the status of this URL
server.write( "<TD>" );
switch( status ) {
case URLStatus.NEW: {
server.write( "<FONT COLOR=\"red\">" );
server.write( "NEW" );
server.write( "</FONT>" );
break;
} case URLStatus.UNCHANGED: {
server.write( "Unchanged" );
break;
} case URLStatus.UNKNOWN: {
server.write( "Unknown" );
break;
} default: {
server.write( "Error" );
break;
}
}
server.writeln( "</TD>" );
server.writeln( "</TR>" );
}
server.writeln( "</TABLE></CENTER>" );
server.writeln( "<P>\n<BR>\n<HR>\n<BR>" );
} catch( WebServiceException e ) {
server.writeln( "<H2>WebService Exception: " + e.getMessage() );
} catch( Exception e ) {
server.writeln( "<H2>Exception: " + e.getMessage() );
}
}
@end-code;
@begin-code Code "IURL_Poller::EndApp(String args[])"
public void EndApp(String args[])
{
}
@end-code;
@end;