Here is a short code snippet that can help people who are writing Java Servlets on their server (e.g using Tomcat) and who want to use the Zoom Search Engine CGI,
// Protocol assumed to be http because no valid certificate is inplace
// This will work even with a site listening on 443, if it also listens on
// a separate port for http
//
// Note that port 81 is hard coded because a request.getServerPort()
// returns the 443 of the servlet
// String url = "http://" + request.getServerName() + ":81" +
// "/cgi-bin/search.cgi?" + request.getQueryString();
out.println( "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"width=\"80%\" style=\"position:absolute; top:52; left:174;\">\n" +
"<tr><td>\n");
URL u = null;
try
{
u = new URL(url);
}
catch (MalformedURLException e)
{
log.debug("Bad URL: Exception = " + e);
}
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream()));
String line;
while ( (line = br.readLine()) != null)
{
out.println(line);
}
br.close();
}
catch (IOException e)
{
log.debug("Unable to read cgi script: Exception = " + e) ;
}
out.println("</td></tr>\n" + "</table>\n");
The above code was submitted by William Hamilton.
------
David
// Protocol assumed to be http because no valid certificate is inplace
// This will work even with a site listening on 443, if it also listens on
// a separate port for http
//
// Note that port 81 is hard coded because a request.getServerPort()
// returns the 443 of the servlet
// String url = "http://" + request.getServerName() + ":81" +
// "/cgi-bin/search.cgi?" + request.getQueryString();
out.println( "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"width=\"80%\" style=\"position:absolute; top:52; left:174;\">\n" +
"<tr><td>\n");
URL u = null;
try
{
u = new URL(url);
}
catch (MalformedURLException e)
{
log.debug("Bad URL: Exception = " + e);
}
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream()));
String line;
while ( (line = br.readLine()) != null)
{
out.println(line);
}
br.close();
}
catch (IOException e)
{
log.debug("Unable to read cgi script: Exception = " + e) ;
}
out.println("</td></tr>\n" + "</table>\n");
The above code was submitted by William Hamilton.
------
David