package isip.java.bullyse.bullydb; import java.io.*; import java.util.*; import java.text.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class nonMember extends HttpServlet { // Initialize BullyDB Object static BullyDB sessionbase = new BullyDB(); // System parameters are stored in the database, retrieve the values // through the BullyDB object. static String SystemURL = sessionbase.getURL(); static String ServletURL = sessionbase.getServletURL(); static String SystemEmail = sessionbase.getEmail(); static String SystemPath = sessionbase.getPath(); static String SystemName = sessionbase.getName(); static String SystemShortName = sessionbase.getShortName(); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Initialize variables String task = request.getParameter("task"); String query = (String)null; ResultSet result = null; String SessionId = "nonMember"; sessionbase.putUser(); // Initialize the output stream. response.setContentType("text/html"); PrintWriter out = response.getWriter(); if(task == null) { sessionbase.printTop(out, 11); out.println("\"Home\"
"); out.println("Welcome to the Bulldog Stock Exchange!
"); sessionbase.displayGraph(out, "1", "SYS", 0); sessionbase.printBot(out, "", 2); out.close(); } else if (task.equals("logout")) { String AccountId = (String)null; HttpSession session = request.getSession(); SessionId = session.getId(); // Retrieve AccountId, make sure the user is logged in before we try to log // him out. AccountId = sessionbase.getAccountId(SessionId); if (AccountId == null) { // User login must have timed in already, so // nothing needs to be done. Simply redirect // to Login page. response.sendRedirect(SystemURL + "/index.html"); } else { // Close the HttpSession sessionbase.doLogout(SessionId); session.invalidate(); // User is logged out, simply send them back to the // Login page response.sendRedirect(SystemURL + "/index.html"); } } else if (task.equals("passChange")) { sessionbase.printTop(out, 12); out.println("\"Home\"
"); out.println("Success:

"); out.println("A new password has been emailed to your account."); sessionbase.printBot(out, "", 2); out.close(); } else if (task.equals("passChangeFail")) { sessionbase.printTop(out, 12); out.println("\"Home\"
"); out.println("Error:

"); out.println("Password not reset. Please go back and make sure you entered the correct Username and Email Address."); sessionbase.printBot(out, "", 2); out.close(); } else if (task.equals("news")) { displayNews(request, response, "nonMember"); } else if (task.equals("showHeadlines")) { displayHeadlines(request, response, "nonMember"); } else if (task.equals("showArchives")) { displayArchives(request, response, "nonMember"); } else if (task.equals("showArticle")) { displayArticle(request, response, "nonMember"); } else if (task.equals("LI")) { String Type = request.getParameter("Type"); if (Type.equals("1")) { sessionbase.printTop(out, 12); out.println("\"Home\"
"); out.println("Not Logged In

"); out.println("You must be logged in to the system to use this page. You don't appear to be logged in to the system, or you have cookies turned off. To use the " + SystemName + ", Cookies must be enabled in your browser properties."); sessionbase.printBot(out, "", 2); out.close(); } else if (Type.equals("2")) { sessionbase.printTop(out, 13); out.println("\"Home\"
"); out.println("Not Logged In

"); out.println("You must be logged in to the system to use this page. You don't appear to be logged in to the system, or you have cookies turned off. To use the " + SystemName + ", Cookies must be enabled in your browser properties."); sessionbase.printBot(out, "", 2); out.close(); } else if (Type.equals("3")) { sessionbase.printTop(out, 14); out.println("\"Home\"
"); out.println("Not Logged In

"); out.println("You must be logged in to the system to use this page. You don't appear to be logged in to the system, or you have cookies turned off. To use the " + SystemName + ", Cookies must be enabled in your browser properties."); sessionbase.printBot(out, "", 2); out.close(); } } else if (task.equals("Quotes")) { displayAll(request, response); } else if (task.equals("viewQuote")) { String Symbol = request.getParameter("Symbol"); displayQuote(Symbol, request, response); } else if (task.equals("password")) { sessionbase.printTop(out, 13); out.println("\"BSE
"); out.println("If you have forgotten your password you must enter your Username and the Email address associated with it and a new password will be emailed to you.
"); out.println("
"); out.println(""); out.println("Username:
"); out.println("Email:
"); out.println("
"); sessionbase.printBot(out, "", 2); out.close(); } else if (task.equals("notloggedin")) { sessionbase.printTop(out, 11); out.println("\"BSE
"); out.println("Not Logged In:
"); out.println("You must be logged in to the system to use this page. You don't appear to be logged in to the system, or you have cookies turned off. To use the Bulldog Stock Exchange, Cookies must be enabled in your browser properties."); sessionbase.printBot(out, "", 2); out.close(); } else if (task.equals("createAccount")) { sessionbase.printTop(out, 13); out.println("\"BSE
"); out.println("Account Creation
"); out.println("Automatic Account creation is not permitted."); out.println("Email " + SystemEmail + " to get an account."); sessionbase.printBot(out, "", 2); out.close(); } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Extract variable that tells what task we are to perform String task = request.getParameter("task"); String query = (String)null; ResultSet result = null; sessionbase.putUser(); // Initialize the output stream. response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = null; String SessionId = (String)null; // Initialize variables boolean Login = false; String username = ""; username += request.getParameter("username"); String password = ""; password += request.getParameter("password"); String Message = ""; int error = 0; if (task.equals("login")) { // Make sure they actually put in a login/password. No need to query the // database if one of these is missing. if (username.length() < 1 || password.length() < 1) { // Open error file Message += "The username or password you entered is invalid.
"; error++; } else { // Check to make sure a valid user was entered String checkUser = ""; query = "select Username from Account where Username = '" + username + "'"; result = sessionbase.doQuery(query); try { while (result.next()) { checkUser += result.getString("Username"); } } catch (Exception e) { e.printStackTrace(); } if (!checkUser.equalsIgnoreCase(username)) { Message += "The username or password you entered is invalid.
"; error++; } else { session = request.getSession(true); // Check to see if the user is logged in already. If so, close // the old session. if (!session.isNew()) { session.invalidate(); session = request.getSession(true); } SessionId = session.getId(); // Check for a user lock query = "select Locked from Account where Username = '" + username + "'"; result = sessionbase.doQuery(query); String LockStatus = (String)null; try { while (result.next()) { LockStatus = result.getString("Locked"); } } catch (Exception e) { e.printStackTrace(); } if (LockStatus.equals("Y")) { // User is locked Message += "Your account has been locked by a " + SystemName + " administrator.
"; error++; } // Check for a System lock. if (sessionbase.checkLock() && !sessionbase.checkRoot(username)) { Message += "Logins are not permitted at this time.
"; error++; } if (error == 0) { // Attempt to log in the user. Login = sessionbase.doLogon(username, password, SessionId); if (Login != true) { // Don't want to leave a session open if the user didn't // successfully log in session.invalidate(); Message += "The username or password you entered is invalid.
"; error++; } } } } if (error > 0) { sessionbase.printTop(out, 11); out.println("\"Home\"

"); out.println("Login Error:"); out.println(Message); sessionbase.printBot(out, "", 2); out.close(); } else { // Create a new session for the user and set the maximum they // can be inactive session.setAttribute("Exchange.user." + sessionbase.getAccountId(SessionId), sessionbase); session.setMaxInactiveInterval(3600); // Update LastLogin on the Account table query = "update Account set LastLogin = NOW() where AccountId = " + sessionbase.getAccountId(SessionId); sessionbase.doUpdate(query, SessionId); // Check to see what user is logging in. If this is the // Administrative user, send them to a different page if (sessionbase.checkRoot(username)) { // Must be admin, redirect to Admin page response.sendRedirect(ServletURL + ".Admin"); } else { response.sendRedirect(ServletURL + ".Portfolio?task=Members"); } } } } public void displayAll(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String query = (String)null; String Name = (String)null; int Tshares = 0; double Ipo = 0.00; double Open = 0.00; double Last = 0.00; int Volume = 0; double Change = 0.00; double WkHi = 0.00; double WkLo = 0.00; double DayHi = 0.00; double DayLo = 0.00; double Previous = 0.00; String fLast = (String)null; String fChange = (String)null; String fLow = (String)null; String fHigh = (String)null; String Symbol = (String)null; ResultSet result = null; double Capitalization = 0.00; boolean member = true; Vector dumpPlace = new Vector(); int i = 0; String SessionId = "nonMember"; // Set up decimal formatting for digits. This will force at least 0.00. DecimalFormat curFormat = new DecimalFormat("$##,###,###,###,###,##0.00"); DecimalFormat numFormat = new DecimalFormat("################0.00"); DecimalFormat intFormat = new DecimalFormat("################0"); // Initialize output stream response.setContentType("text/html"); PrintWriter out=response.getWriter(); // Extract Company info from the database. A null ResultSet means the company // must not be in the database. query = "select * from Companies where Symbol != 'SYS' order by Symbol"; result = sessionbase.doQuery(query); try { while (result.next()) { Symbol = result.getString("Symbol"); Last = result.getDouble("Last"); DayHi = result.getDouble("DayHi"); DayLo = result.getDouble("DayLo"); Volume = result.getInt("Volume"); dumpPlace.addElement(new Companies(Symbol, DayHi, DayLo, Last, Volume)); } } catch (Exception e) { e.printStackTrace(); } sessionbase.printTop(out, 15); out.println("\"BSE
"); out.println(""); out.println(""); out.println("
"); out.println(""); out.println(""); out.println(""); Companies Company = new Companies(); int vSize = dumpPlace.size(); for (i = 0 ; i < vSize ; i++) { Company = (Companies)dumpPlace.elementAt(i); Symbol = Company.getSymbol(); DayHi = Company.getHigh(); DayLo = Company.getLow(); Last = Company.getCurrent(); Volume = Company.getVolume(); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); } out.println("
SymbolHighLowCurrentVolume
" + Symbol + "" + numFormat.format(DayHi) + "" + numFormat.format(DayLo) + "" + numFormat.format(Last) + "" + Volume + "
"); out.println("
"); sessionbase.printBot(out, "", 2); out.close(); } public void displayQuote(String Symbol, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String Type = request.getParameter("Type"); String query = (String)null; String Name = (String)null; int Tshares = 0; double Ipo = 0.00; double Open = 0.00; double Last = 0.00; int Volume = 0; double Change = 0.00; double WkHi = 0.00; double WkLo = 0.00; double DayHi = 0.00; double DayLo = 0.00; double Previous = 0.00; String fLast = (String)null; String fChange = (String)null; String fLow = (String)null; String fHigh = (String)null; ResultSet result = null; double Capitalization = 0.00; ResultSet result2 = null; double userValue = 0; int userShares = 0; String userName = (String)null; boolean member = true; String Locked = (String)null; String SessionId = "nonMember"; // Set up decimal formatting for digits. This will force at least 0.00. DecimalFormat curFormat = new DecimalFormat("$##,###,###,###,###,##0.00"); DecimalFormat numFormat = new DecimalFormat("################0.00"); DecimalFormat intFormat = new DecimalFormat("################0"); // Initialize output stream response.setContentType("text/html"); PrintWriter out=response.getWriter(); if (Type == null) { Type = "1"; } // Extract Company info from the database. A null ResultSet means the company // must not be in the database. query = "select * from Companies where Symbol = '" + Symbol + "'"; result = sessionbase.doQuery(query); try { while(result.next()) { Name = result.getString("Name"); Tshares = result.getInt("Tshares"); Open = result.getDouble("Open"); Last = result.getDouble("Last"); Volume = result.getInt("Volume"); WkHi = result.getDouble("52WkHi"); WkLo = result.getDouble("52WkLo"); DayHi = result.getDouble("DayHi"); DayLo = result.getDouble("DayLo"); Previous = result.getDouble("Previous"); Locked = result.getString("Locked"); } } catch(Exception e) { e.printStackTrace(); } Change = Last - Previous; // Calculating an accurate total Market Cap is a little // trickier. query = "select Username from Account where Username != 'root' order by Username"; result2 = sessionbase.doQuery(query); try { while (result2.next()) { userName = result2.getString("Username"); query = "select * from " + userName + " where Symbol = '" + Symbol + "' and Trans != 'B' and Trans != 'FB'"; result = sessionbase.doQuery(query); while (result.next()) { userValue = result.getDouble("boughtAt"); userShares = result.getInt("NumShares"); Capitalization += (userValue * userShares); } } } catch (Exception e) { e.printStackTrace(); } if (Name == null) { response.sendRedirect(ServletURL + ".Quotes?Task=invalid&Link=2"); out.close(); } else { sessionbase.printTop(out, 15); out.println("\"BSE
"); out.println(""); out.println(""); out.println("
"); out.println(""); out.println(""); out.println(""); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(" "); out.println(""); if (Locked.equals("Y")) { out.println(" "); } out.println("
Today with " + Name + " (" + Symbol + ")
Today's Open:" + numFormat.format(Open) + " Yesterday's Close:" + numFormat.format(Previous) + "
Current Price:" + numFormat.format(Last) + "Change:" + numFormat.format(Change) + "
Today's Low:" + numFormat.format(DayLo) + "Today's High:" + numFormat.format(DayHi) + "
52wk High:" + numFormat.format(WkHi) + "52wk Low:" + numFormat.format(WkLo) + "
Volume:" + Volume + "
Market Capitalization" + curFormat.format(Capitalization) + "
"); out.println("This company is currently in Locked status. "); out.println("Buying and Selling cannot take place for this company until "); out.println("it is unlocked.
"); // Rude and crude to push the graph down - but it works. out.println("











"); // Display the Company graph sessionbase.displayGraph(out, Type, Symbol, 3); out.println(""); sessionbase.printBot(out, "", 2); out.close(); } } public void displayNews(HttpServletRequest request, HttpServletResponse response, String SessionId) throws IOException, ServletException { String query = (String)null; ResultSet result = null; // Initialize the output stream response.setContentType("text/html"); PrintWriter out = response.getWriter(); // Let's get the news sessionbase.printTop(out, 16); out.println("\"BSE
"); // Get the Front Article String frontTitle = (String)null; String frontAuthor = (String)null; int frontId = 0; java.util.Date frontDate = new java.util.Date(); java.util.Date frontTime = new java.util.Date(); Locale locale = new Locale("en","US"); // Set the format for time and date DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale); String frontStory = (String)null; query = "select Title, Author, Date, Story, Id from News where Type = 3"; result = sessionbase.doQuery(query, SessionId); try { while (result.next()) { frontTitle = result.getString("Title"); frontAuthor = result.getString("Author"); frontDate = result.getDate("Date"); frontTime = result.getTime("Date"); frontStory = result.getString("Story"); frontId = result.getInt("Id"); } } catch (Exception e) { e.printStackTrace(); } // Get Author's Full Name query = "select Fname, Lname from Account where Username = '" + frontAuthor + "'"; result = sessionbase.doQuery(query, SessionId); String frontFullAuthor = ""; try { while (result.next()) { frontFullAuthor += result.getString("Fname"); frontFullAuthor += " "; frontFullAuthor += result.getString("Lname"); } } catch (Exception e) { e.printStackTrace(); } out.println(""); out.println("Article Submitted: " + dateFormat.format(frontDate) + " at " + timeFormat.format(frontTime) + "
"); out.println("" + frontTitle + "
"); out.println(frontStory + "
"); out.println("

"); out.println("Article submitted by: " + frontFullAuthor + "

"); // Get Breaking News Links query = "select Title, Date, Id from News where Type = 2"; result = sessionbase.doQuery(query, SessionId); String breakingTitle = (String)null; java.util.Date breakingDate = new java.util.Date(); java.util.Date breakingTime = new java.util.Date(); String breakingId = (String)null; // Make sure there are any Breaking News articles int bId = 0; query = "select Id from News where Type = 2"; result = sessionbase.doQuery(query, SessionId); try { while (result.next()) { bId = result.getInt("Id"); } } catch (Exception e) { e.printStackTrace(); } if (bId > 0) { out.println("
"); out.println("Breaking News
"); try { while (result.next()) { breakingTitle = result.getString("Title"); breakingDate = result.getDate("Date"); breakingId = result.getString("Id"); out.println("" + dateFormat.format(breakingDate) + " " + breakingTitle + "
"); } } catch (Exception e) { e.printStackTrace(); } } out.println("
MoreView all headlines...

"); out.println(""); sessionbase.printBot(out, "", 2); out.close(); } public void displayHeadlines(HttpServletRequest request, HttpServletResponse response, String SessionId) throws IOException, ServletException { String query = (String)null; ResultSet result = null; // Initialize the output stream response.setContentType("text/html"); PrintWriter out = response.getWriter(); // Let's get the news sessionbase.printTop(out, 16); out.println("\"Admin\"

"); java.util.Date frontDate = new java.util.Date(); java.util.Date frontTime = new java.util.Date(); Locale locale = new Locale("en","US"); // Set the format for time and date DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale); java.util.Date curDate = new java.util.Date(); int Day = curDate.getDate(); int Month = (curDate.getMonth()) + 1; int Year = (curDate.getYear()) + 1900; Day = Day - 14; if (Day < 1) { Month = Month - 1; if (Month == 1) { Day = 31 + Day; } else if (Month == 2) { Day = 28 + Day; } else if (Month == 3) { Day = 31 + Day; } else if (Month == 4) { Day = 30 + Day; } else if (Month == 5) { Day = 31 + Day; } else if (Month == 6) { Day = 30 + Day; } else if (Month == 7) { Day = 31 + Day; } else if (Month == 8) { Day = 31 + Day; } else if (Month == 9) { Day = 30 + Day; } else if (Month == 10) { Day = 31 + Day; } else if (Month == 11) { Day = 30 + Day; } else if (Month == 12) { Day = 31 + Day; } if (Month < 1) { Month = 12; Year = Year - 1; } } // Get all Headlines String headTitle = (String)null; String headId = (String)null; java.util.Date headDate = new java.util.Date(); java.util.Date headDateO = new java.util.Date(); query = "select Title, Date, Id from News where Date >= " + Year + "-" + Month + "-" + Day + " order by Date desc"; result = sessionbase.doQuery(query, SessionId); int i = 0; out.println("These articles have been submitted within the last two weeks.
"); out.println("To view older articles, visit the archives."); out.println("

News Articles

"); try { while (result.next()) { i++; headDateO = headDate; headTitle = result.getString("Title"); headDate = result.getDate("Date"); headId = result.getString("Id"); if (!headDate.equals(headDateO)) { if (i > 1) { out.println("
"); } out.println("" + shortFormat.format(headDate) + "
"); out.println("° " + headTitle + "
"); } else { out.println("° " + headTitle + "
"); } } } catch (Exception e) { e.printStackTrace(); } if (i == 0) { out.println("No New Articles
"); } out.println("
MoreView old news...

"); sessionbase.printBot(out, "", 2); out.close(); } public void displayArchives(HttpServletRequest request, HttpServletResponse response, String SessionId) throws IOException, ServletException { String query = (String)null; ResultSet result = null; // Initialize the output stream response.setContentType("text/html"); PrintWriter out = response.getWriter(); // Let's get the news sessionbase.printTop(out, 16); out.println("\"Admin\"

"); java.util.Date frontDate = new java.util.Date(); java.util.Date frontTime = new java.util.Date(); Locale locale = new Locale("en","US"); // Set the format for time and date DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale); java.util.Date curDate = new java.util.Date(); int Day = curDate.getDate(); int Month = (curDate.getMonth()) + 1; int Year = (curDate.getYear()) + 1900; Day = Day - 14; if (Day < 1) { Month = Month - 1; if (Month == 1) { Day = 31 + Day; } else if (Month == 2) { Day = 28 + Day; } else if (Month == 3) { Day = 31 + Day; } else if (Month == 4) { Day = 30 + Day; } else if (Month == 5) { Day = 31 + Day; } else if (Month == 6) { Day = 30 + Day; } else if (Month == 7) { Day = 31 + Day; } else if (Month == 8) { Day = 31 + Day; } else if (Month == 9) { Day = 30 + Day; } else if (Month == 10) { Day = 31 + Day; } else if (Month == 11) { Day = 30 + Day; } else if (Month == 12) { Day = 31 + Day; } if (Month < 1) { Month = 12; Year = Year - 1; } } // Get all Headlines String headTitle = (String)null; String headId = (String)null; java.util.Date headDate = new java.util.Date(); java.util.Date headDateO = new java.util.Date(); query = "select Title, Date, Id from News where Date < " + Year + "-" + Month + "-" + Day + " order by Date desc"; result = sessionbase.doQuery(query, SessionId); int i = 0; out.println("These articles are all over two weeks old. To view newer "); out.println("articles, visit the headlines."); out.println("

News Articles

"); try { while (result.next()) { i++; headDateO = headDate; headTitle = result.getString("Title"); headDate = result.getDate("Date"); headId = result.getString("Id"); if (!headDate.equals(headDateO)) { if (i > 1) { out.println("
"); } out.println("" + shortFormat.format(headDate) + "
"); out.println("° " + headTitle + "
"); } else { out.println("° " + headTitle + "
"); } } } catch (Exception e) { e.printStackTrace(); } if (i == 0) { out.println("No Old Articles
"); } out.println("
MoreView all headlines...

"); sessionbase.printBot(out, "", 2); out.close(); } public void displayArticle(HttpServletRequest request, HttpServletResponse response, String SessionId) throws IOException, ServletException { String Id = request.getParameter("Id"); String query = (String)null; ResultSet result = null; // Initialize the output stream response.setContentType("text/html"); PrintWriter out = response.getWriter(); // Get the Article String Title = (String)null; String Author = (String)null; java.util.Date Date = new java.util.Date(); java.util.Date Time = new java.util.Date(); Locale locale = new Locale("en","US"); // Set the format for time and date DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale); String Story = (String)null; query = "select Title, Author, Date, Story from News where Id = " + Id; result = sessionbase.doQuery(query, SessionId); try { while (result.next()) { Title = result.getString("Title"); Author = result.getString("Author"); Date = result.getDate("Date"); Time = result.getTime("Date"); Story = result.getString("Story"); } } catch (Exception e) { e.printStackTrace(); } // Get Author's Full Name query = "select Fname, Lname from Account where Username = '" + Author + "'"; result = sessionbase.doQuery(query, SessionId); String FullAuthor = ""; try { while (result.next()) { FullAuthor += result.getString("Fname"); FullAuthor += " "; FullAuthor += result.getString("Lname"); } } catch (Exception e) { e.printStackTrace(); } sessionbase.printTop(out, 16); out.println("\"BSE
"); out.println("

"); out.println("Article Submitted: " + dateFormat.format(Date) + " at " + timeFormat.format(Time) + "

"); out.println("" + Title + "
"); out.println(Story + "
"); out.println("

"); out.println("Article submitted by: " + FullAuthor + "
"); out.println("

"); // Get Breaking News Links // Make sure there are Breaking News articles int bId = 0; query = "select COUNT(Id) from News where Type = 2"; result = sessionbase.doQuery(query, SessionId); try { while (result.next()) { bId = result.getInt("COUNT(Id)"); } } catch (Exception e) { e.printStackTrace(); } if (bId > 0) { query = "select Title, Date, Id from News where Type = 2"; result = sessionbase.doQuery(query, SessionId); String breakingTitle = (String)null; java.util.Date breakingDate = new java.util.Date(); java.util.Date breakingTime = new java.util.Date(); String breakingId = (String)null; out.println("

"); out.println("Breaking News
"); try { while (result.next()) { breakingTitle = result.getString("Title"); breakingDate = result.getDate("Date"); breakingId = result.getString("Id"); out.println("" + dateFormat.format(breakingDate) + " " + breakingTitle + "
"); } } catch (Exception e) { e.printStackTrace(); } } out.println("
MoreView all headlines...

"); sessionbase.printBot(out, "", 2); out.close(); } static public void reload() { SystemURL = sessionbase.getURL(); ServletURL = sessionbase.getServletURL(); SystemEmail = sessionbase.getEmail(); SystemPath = sessionbase.getPath(); SystemName = sessionbase.getName(); SystemShortName = sessionbase.getShortName(); } }