PROBLEM
-----------------
when I remove "response.getText()" from the below code and check "response.getContentType()" the output is....................
TYPE : application/octet-stream
EXCEPTION : com.meterware.httpunit.NotHTMLException: The content type of the response is 'application/octet-stream': it must be 'text/html' in order to be recognized as HTML
and when I use the code below it gives the output given below.
I want to get the links on the ".jsp" page......... can anyone help me and tell where am I going wrong ??????????????////
CODE
----------
import com.meterware.httpunit.*;
public class WebsiteHostTest {
public static void main(String[] args){
String host = "localhost/check.jsp";
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://" + host);
System.out.println("REQUEST : " + request);
System.out.println("");
To avoid this problem I have modified the method isHTML of the class WebResponse adding the content-type "application/octet-stream", but I don't know if there is better solutions
PROBLEM
-----------------
when I remove "response.getText()" from the below code and check "response.getContentType()" the output is....................
TYPE : application/octet-stream
EXCEPTION : com.meterware.httpunit.NotHTMLException: The content type of the response is 'application/octet-stream': it must be 'text/html' in order to be recognized as HTML
and when I use the code below it gives the output given below.
I want to get the links on the ".jsp" page......... can anyone help me and tell where am I going wrong ??????????????////
CODE
----------
import com.meterware.httpunit.*;
public class WebsiteHostTest {
public static void main(String[] args){
String host = "localhost/check.jsp";
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://" + host);
System.out.println("REQUEST : " + request);
System.out.println("");
try{
WebResponse response = wc.getResponse(request);
System.out.println("RESPONSE : " + response);
System.out.println("");
response.getText();
System.out.println("TYPE : " + response.getContentType());
System.out.println("");
WebLink[] links = response.getLinks();
System.out.println("No. of Links : " + links.length);
}
catch (Exception e){
System.out.println("EXCEPTION : " + e);
}
}
}
OUTPUT
--------------
REQUEST : GET request for (null) http://localhost/check.jsp
RESPONSE : HttpWebResponse [url=http://localhost/check.jsp; headers=
CONTENT-TYPE: application/octet-stream
CONTENT-LENGTH: 92971
LAST-MODIFIED: Tue, 29 Mar 2005 11:51:01 GMT
X-POWERED-BY: ASP.NET
SERVER: Microsoft-IIS/5.0
DATE: Tue, 29 Mar 2005 11:54:56 GMT
ETAG: "9e3a73945534c51:d81"
ACCEPT-RANGES: bytes ]
TYPE : text/html
EXCEPTION : java.lang.RuntimeException: Error loading included script: java.io.IOException
To avoid this problem I have modified the method isHTML of the class WebResponse adding the content-type "application/octet-stream", but I don't know if there is better solutions
public boolean isHTML() {
return getContentType().equalsIgnoreCase( HTML_CONTENT ) ||
getContentType().equalsIgnoreCase( FAUX_XHTML_CONTENT ) ||
getContentType().equalsIgnoreCase( XHTML_CONTENT ) ||
getContentType().equalsIgnoreCase( "application/octet-stream" );
}