catlett 01/09/05 11:13:57
Modified: scrape/src/org/apache/taglibs/scrape PageData.java
Log:
changed back to use the HttpConnection class that I wrote instead of casting the
connection to a HttpURLConnection
Revision Changes Path
1.4 +20 -9
jakarta-taglibs/scrape/src/org/apache/taglibs/scrape/PageData.java
Index: PageData.java
===================================================================
RCS file:
/home/cvs/jakarta-taglibs/scrape/src/org/apache/taglibs/scrape/PageData.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PageData.java 2001/08/28 17:14:32 1.3
+++ PageData.java 2001/09/05 18:13:57 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-taglibs/scrape/src/org/apache/taglibs/scrape/PageData.java,v 1.3
2001/08/28 17:14:32 catlett Exp $
- * $Revision: 1.3 $
- * $Date: 2001/08/28 17:14:32 $
+ * $Header:
/home/cvs/jakarta-taglibs/scrape/src/org/apache/taglibs/scrape/PageData.java,v 1.4
2001/09/05 18:13:57 catlett Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/09/05 18:13:57 $
*
* ====================================================================
*
@@ -373,8 +373,13 @@
* newflag it will wait for the thread to finish running, otherwise it will
* just fall through and return the already stored results
*
+ * @param url url of the page to be scraped
+ * @param time length of time to wait before rescrape
+ * @param proxy boolean value that says whether or not to use a proxy server
+ * @param pc PageContext for this JSP page
+ *
*/
- public void scrapePage(URL url, long time, PageContext pc)
+ public void scrapePage(URL url, long time, boolean proxy, PageContext pc)
throws JspException {
long currenttime = new Date().getTime(); // get the current time
@@ -385,7 +390,7 @@
synchronized (scraping) {
if ((page == null) || !page.isAlive()) {
// create thread page if it doesn't exist
- page = new Page(url, this, pc);
+ page = new Page(url, this, proxy, pc);
}
if (((currenttime - lastscrape) > time) || newflag ||
changeflag) {
@@ -425,7 +430,8 @@
*/
class Page extends Thread {
- private HttpURLConnection connection; // object to create an http request
+ private HttpConnection connection; // object to create an http request
+ //private HttpURLConnection connection; // object to create an http request
private long lastmodified; // time the page was last modified
private long expires; // http header = time the page expires
private URL url; // url from the page to be scraped
@@ -436,10 +442,13 @@
private final long MAX_BUFFER_SIZE = 50000;
// pagecontext that the servlet resides in, used for logging to the server
private PageContext pageContext;
+ // value determines if a proxy server is to be used for the http connection
+ private boolean proxy;
- Page(URL url, PageData page, PageContext pc) {
+ Page(URL url, PageData page, boolean proxie, PageContext pc) {
this.url = url;
pagedata = page;
+ proxy = proxie;
pageContext = pc;
}
@@ -449,10 +458,10 @@
// make http connection to url
try {
// create new HttpUrlConnection
- //connection = new HttpConnection(url);
+ connection = new HttpConnection(url);
// change from Kenneth Meltsner bypasses the need for a seperate
// HttpURLConnection class
- connection = (HttpURLConnection) url.openConnection();
+ //connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
@@ -617,6 +626,8 @@
StringBuffer matchbuffer = new StringBuffer();
matchbuffer.append(result.toString());
match = new String(matchbuffer);
+
+ System.out.println(match);
// default value is false and begin and end anchors are not part of
// the scrape