Hello..Im trying to read the HTML from a URL and I threw in yahoo.com as a test...for some reason, "n.readLine()" is coming back as NULL and the while loop fails...and ideas??


<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page language="java" %>
<%@ page import="trader.webservices.util.Utils" %>
<%@ page import="trader.webservices.data.UserDataVO" %>
<%@ page import="trader.webservices.data.UserInfoDAO" %>
<%@ page import="trader.aabamail.AABAmailDAO" %>
<%@ page import="trader.aabamail.OutgoingMessage" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 	UserDataVO userData = null;
 	//String username = request.getParameter("username");
	//String password = request.getParameter("password");
	String flyRequest = request.getParameter("flyRequest");
	String email = request.getParameter("emailAdd");
	String domainName	= UserInfoDAO.removeHostRedirection(request.getServerName());
	String adminServer = request.getServerName();
	String javaAdminServer = request.getServerName();
	if (request.getServerName().equals("localhost") || request.getServerName().startsWith("199")) {
			adminServer = "cpanel.homes.com";
			javaAdminServer = "localhost:8080";
			userData = UserInfoDAO.getUserInfo(domainName);
			String accountName = userData.getAcctName();
	URL flyUrl = new URL("http://www.yahoo.com/");
	BufferedReader in = new BufferedReader(new InputStreamReader(flyUrl.openStream()));
	String flyerInputLine;
	while ((flyerInputLine = in.readLine()) != null)



	//This is the body of the email
   OutgoingMessage msg = new OutgoingMessage();
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Email Flyer</title>
   <link rel="stylesheet" type="text/css" media="screen" href="/Listings/resources/css/cp-contentwell.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="/Listings/resources/css/cp-tablesort.css" />
		<!--[if IE]>
		<link rel="stylesheet" type="text/css" media="screen" href="/Listings/resources/css/cp-ie.css" />
       <div id="cWell">
			<h1 class="tab4dark">Email Flyer</h1>

				<div id="msgBox2">
						<li>Your flyer has been sent. Thank you!<%=flyRequest%><%=flyerInputLine%>

You need to assign flyerInputLine to something, before the while loop comes around and in.readLine() makes it null when the while loop reaches the (last line of the loop + 1).

When the while loop reaches the (last line + 1) -> flyerInputLine = in.readLine() ... well in.readLine() is null, which is why the while loop ends and why you keep getting null.

Solution: Define a string before the while loop and append the values to the string, while inside the loop:

String s = new String();
while ((flyerInputLine = in.readLine()) != null)
    s += flyerInputLine;