Hi All,
I am using HtmlUnit for posting the data to the server for handling the interactive websites. But for some of the sites I got the exception "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space".
For other sites the code is working prooperly. My code is as below with the URL which is giving exception.
import java.util.List;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
import java.io.File;
import java.io.PrintWriter;
public class test_html
{
public static void main(String[] args) throws Exception
{
WebClient webClient =null;
HtmlPage page=null;
HtmlForm form=null;
int newMessageCount = 0;
PrintWriter pw=null;
pw=new PrintWriter(new File("file_html.txt"));
webClient=new WebClient(BrowserVersion.FIREFOX_3);
webClient.setThrowExceptionOnScriptError(false);
webClient.setJavaScriptEnabled(false);
page= (HtmlPage) webClient.getPage("http://www.msnbc.msn.com/id/3053415/deck/tmobile");
form= page.getFormByName("fgl");
form.getInputByName("txtZip").setValueAttribute("12345");
page = (HtmlPage) form.getButtonByName("ZipSubmit").click();
pw.write(page.asText());
pw.close();
}
}
Please help me to solve this exception.
Thanks & Regards,
Jyotin