473,738 Members | 10,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help-My table does not get displayed

41 New Member
Hi guys,

Having a problem, my table does not get displayed, when i load the page it gives me the following error(p.s-the codes below):


Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*,java.io.*" %>
  3. <%@ page import="testBean.TestBean" %>
  4.  
  5.  
  6. <html>
  7. <head>
  8.  
  9. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15. <hr></hr>
  16.  
  17. <center>
  18.  
  19. <h1> 
  20.  
  21.  Weather Forecast</h1>
  22.  
  23. <table>
  24. <tr><th>Todays Forecast</th></tr>
  25.  
  26.  <tr>
  27.   <th>Temperature</th>
  28.   <th>Light</th> 
  29.  </tr>
  30.  
  31. <%
  32.  
  33.   String valString;
  34.   BufferedReader dataFile = null;
  35.    try {
  36.    String[] temp = {"Temperature", "Light"};
  37.    int recCount = 0;
  38.     FileReader dFile = new FileReader("w:/www/DataFile.txt");
  39.        dataFile = new BufferedReader(dFile);
  40.     valString = dataFile.readLine();
  41.     while(valString != null){
  42.  %>
  43.  
  44.  
  45.   <tr>
  46.   <td><%=temp[recCount]%></td>
  47.   <td><%=valString%></td>
  48.  </tr>
  49. <%
  50.      recCount++;
  51.      //out.println(valString);
  52.      valString = dataFile.readLine();
  53.     }
  54.    }
  55.    catch (FileNotFoundException e) {
  56.    System.err.println("FileStreamsTest: " + e);
  57.   }
  58.   catch(IOException iOE) {
  59.    iOE.printStackTrace();
  60.   }
  61.   finally {
  62.    dataFile.close();
  63.   }
  64.  
  65.  %>
  66.  
  67. </table>
  68.  
  69.  
  70.  <jsp:useBean id="temp"  class="TestBean" /> 
  71.  
  72.  <br><br><br>
  73.  
  74. <a href="test.html"> Local Five day forecast </a>
  75.  
  76. <br><br><br><br><br><br><br>
  77. <table>
  78. <tr><TD><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></TD><TD><h4> <%= temp.post() %> </h4></TD> </tr>
  79. </table>
  80.  
  81. <br><br><br><br><br><br><br>
  82.  
  83. <hr></hr>
  84.  
  85. </body>
  86. </html>
  87.  
  88.  
Feb 21 '07 #1
15 1584
Naha
41 New Member
Hi guys,

Having a problem, my table does not get displayed, when i load the page it gives me the following error(p.s-the codes below):

Expand|Select|Wrap|Line Numbers
  1. HTTP Status 500 - 
  2.  
  3. --------------------------------------------------------------------------------
  4.  
  5. type Exception report
  6.  
  7. message 
  8.  
  9. description The server encountered an internal error () that prevented it from fulfilling this request.
  10.  
  11. exception 
  12.  
  13. org.apache.jasper.JasperException: 2
  14.     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  15.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
  16.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  17.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  18.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  19.  
  20.  
  21. root cause 
  22.  
  23. java.lang.ArrayIndexOutOfBoundsException: 2
  24.     org.apache.jsp.website.weather_jsp._jspService(weather_jsp.java:93)
  25.     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  26.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  27.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
  28.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  29.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  30.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  31.  
  32.  
  33. note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
  34.  
  35.  
  36. --------------------------------------------------------------------------------
  37.  
  38. Apache Tomcat/5.5.17
  39.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*,java.io.*" %>
  3. <%@ page import="testBean.TestBean" %>
  4.  
  5.  
  6. <html>
  7. <head>
  8.  
  9. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15. <hr></hr>
  16.  
  17. <center>
  18.  
  19. <h1> 
  20.  
  21.  Weather Forecast</h1>
  22.  
  23. <table>
  24. <tr><th>Todays Forecast</th></tr>
  25.  
  26.  <tr>
  27.   <th>Temperature</th>
  28.   <th>Light</th> 
  29.  </tr>
  30.  
  31. <%
  32.  
  33.   String valString;
  34.   BufferedReader dataFile = null;
  35.    try {
  36.    String[] temp = {"Temperature", "Light"};
  37.    int recCount = 0;
  38.     FileReader dFile = new FileReader("w:/www/DataFile.txt");
  39.        dataFile = new BufferedReader(dFile);
  40.     valString = dataFile.readLine();
  41.     while(valString != null){
  42.  %>
  43.  
  44.  
  45.   <tr>
  46.   <td><%=temp[recCount]%></td>
  47.   <td><%=valString%></td>
  48.  </tr>
  49. <%
  50.      recCount++;
  51.      //out.println(valString);
  52.      valString = dataFile.readLine();
  53.     }
  54.    }
  55.    catch (FileNotFoundException e) {
  56.    System.err.println("FileStreamsTest: " + e);
  57.   }
  58.   catch(IOException iOE) {
  59.    iOE.printStackTrace();
  60.   }
  61.   finally {
  62.    dataFile.close();
  63.   }
  64.  
  65.  %>
  66.  
  67. </table>
  68.  
  69.  
  70.  <jsp:useBean id="temp"  class="TestBean" /> 
  71.  
  72.  <br><br><br>
  73.  
  74. <a href="test.html"> Local Five day forecast </a>
  75.  
  76. <br><br><br><br><br><br><br>
  77. <table>
  78. <tr><TD><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></TD><TD><h4> <%= temp.post() %> </h4></TD> </tr>
  79. </table>
  80.  
  81. <br><br><br><br><br><br><br>
  82.  
  83. <hr></hr>
  84.  
  85. </body>
  86. </html>
  87.  
  88.  
Feb 21 '07 #2
r035198x
13,262 MVP
Hi guys,

Having a problem, my table does not get displayed, when i load the page it gives me the following error(p.s-the codes below):

Expand|Select|Wrap|Line Numbers
  1. HTTP Status 500 - 
  2.  
  3. --------------------------------------------------------------------------------
  4.  
  5. type Exception report
  6.  
  7. message 
  8.  
  9. description The server encountered an internal error () that prevented it from fulfilling this request.
  10.  
  11. exception 
  12.  
  13. org.apache.jasper.JasperException: 2
  14.     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  15.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
  16.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  17.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  18.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  19.  
  20.  
  21. root cause 
  22.  
  23. java.lang.ArrayIndexOutOfBoundsException: 2
  24.     org.apache.jsp.website.weather_jsp._jspService(weather_jsp.java:93)
  25.     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  26.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  27.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
  28.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  29.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  30.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  31.  
  32.  
  33. note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
  34.  
  35.  
  36. --------------------------------------------------------------------------------
  37.  
  38. Apache Tomcat/5.5.17
  39.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*,java.io.*" %>
  3. <%@ page import="testBean.TestBean" %>
  4.  
  5.  
  6. <html>
  7. <head>
  8.  
  9. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15. <hr></hr>
  16.  
  17. <center>
  18.  
  19. <h1> 
  20.  
  21. Weather Forecast</h1>
  22.  
  23. <table>
  24. <tr><th>Todays Forecast</th></tr>
  25.  
  26. <tr>
  27. <th>Temperature</th>
  28. <th>Light</th> 
  29. </tr>
  30.  
  31. <%
  32.  
  33. String valString;
  34. BufferedReader dataFile = null;
  35. try {
  36. String[] temp = {"Temperature", "Light"};
  37. int recCount = 0;
  38.     FileReader dFile = new FileReader("w:/www/DataFile.txt");
  39.      dataFile = new BufferedReader(dFile);
  40.     valString = dataFile.readLine();
  41.     while(valString != null){
  42. %>
  43.  
  44.  
  45. <tr>
  46. <td><%=temp[recCount]%></td>
  47. <td><%=valString%></td>
  48. </tr>
  49. <%
  50.      recCount++;
  51.      //out.println(valString);
  52.      valString = dataFile.readLine();
  53.     }
  54. }
  55. catch (FileNotFoundException e) {
  56. System.err.println("FileStreamsTest: " + e);
  57. }
  58. catch(IOException iOE) {
  59. iOE.printStackTrace();
  60. }
  61. finally {
  62. dataFile.close();
  63. }
  64.  
  65. %>
  66.  
  67. </table>
  68.  
  69.  
  70. <jsp:useBean id="temp" class="TestBean" /> 
  71.  
  72. <br><br><br>
  73.  
  74. <a href="test.html"> Local Five day forecast </a>
  75.  
  76. <br><br><br><br><br><br><br>
  77. <table>
  78. <tr><TD><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></TD><TD><h4> <%= temp.post() %> </h4></TD> </tr>
  79. </table>
  80.  
  81. <br><br><br><br><br><br><br>
  82.  
  83. <hr></hr>
  84.  
  85. </body>
  86. </html>
  87.  
  88.  
The size of the array temp is smaller than the number of lines in the file.
You have

Temperature | someValue
Light | someValue
? | someValue

That is what is causing the exception. Make sure the design of your table is correct and fits the data that you have.
Feb 21 '07 #3
Naha
41 New Member
Hi there,

i made alterations to the code, whereby i have created to separate tables for light and temperature, which reads two different files, although both the tables and data gets displayed, each table has two addtional empty rows printed to it, like below. How do I stop this from happening??


Expand|Select|Wrap|Line Numbers
  1.  
  2.         Todays Temperature  
  3.  
  4. Outlook: image1.gif  
  5. Temperature: Todays temperature is: 90 degrees  
  6. Temperature : 
  7. Temperature  :
  8.  
  9. Todays Light Intensity  
  10.  
  11. Outlook: image2.gif  
  12. Light: Todays temperature is: 90 degrees  
  13. Light : 
  14. Light  :
  15.  
  16.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*,java.io.*" %>
  3.  
  4.  
  5.  
  6. <html>
  7. <head>
  8.  
  9. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15. <hr></hr>
  16.  
  17. <center>
  18.  
  19. <h1> 
  20.  
  21.  Weather Forecast</h1>
  22.  <br><br>
  23.  
  24.  
  25.  <a href="test.html"> Local Five day forecast </a>
  26.  
  27.  <br><br><br><br>
  28.  
  29.  <table border=1   cellpadding=5 cellspacing=0 width="50%">
  30. <tr><th colspan=2>Todays Temperature </th></tr>
  31.  
  32. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  33.  
  34.  
  35.  <% 
  36.  
  37.   String tempString;
  38.   BufferedReader dataFile1 = null;
  39.    try {
  40.    //String[] temp = {"Temperature", "Light"};
  41.    int recCount1 = 0;
  42.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  43.        dataFile1 = new BufferedReader(dFile1);
  44.     tempString = dataFile1.readLine();
  45.     while(tempString != null){
  46. %>
  47.  
  48.  
  49.  
  50.  <tr ><th>Temperature</th><td><%=tempString%></td> </tr>
  51.  
  52.  
  53.  
  54.  
  55. <%    
  56.  
  57.      recCount1++;
  58.      //out.println(valString);
  59.      tempString = dataFile1.readLine();
  60.     }
  61.    }
  62.    catch (FileNotFoundException e) {
  63.    System.err.println("FileStreamsTest: " + e);
  64.   }
  65.   catch(IOException iOE) {
  66.    iOE.printStackTrace();
  67.   }
  68.   finally {
  69.    dataFile1.close();
  70.   }
  71.  
  72. %>
  73.  
  74. </table>
  75. <br><br><br>
  76.  
  77.  
  78. <table border=1   cellpadding=5 cellspacing=0 width="50%">
  79. <tr><th colspan=2>Todays Light Intensity</th></tr>
  80.  
  81. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  82.  
  83.  
  84.  <% 
  85.  
  86.   String valString;
  87.   BufferedReader dataFile = null;
  88.    try {
  89.    //String[] temp = {"Temperature", "Light"};
  90.    int recCount = 0;
  91.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  92.        dataFile = new BufferedReader(dFile);
  93.     valString = dataFile.readLine();
  94.     while(valString != null){
  95. %>
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  <tr><th>Light</th>    <td><%=valString%></td> </tr>
  102.  
  103.  
  104. <%    
  105.  
  106.      recCount++;
  107.      //out.println(valString);
  108.      valString = dataFile.readLine();
  109.     }
  110.    }
  111.    catch (FileNotFoundException e) {
  112.    System.err.println("FileStreamsTest: " + e);
  113.   }
  114.   catch(IOException iOE) {
  115.    iOE.printStackTrace();
  116.   }
  117.   finally {
  118.    dataFile.close();
  119.   }
  120.  
  121. %>
  122.  </table>
  123.  
  124.  
  125. <br><br><br><br><br><br><br><br><br>
  126.  
  127. <hr></hr>
  128.  
  129. </body>
  130. </html>
  131.  
  132.  
Feb 22 '07 #4
r035198x
13,262 MVP
Hi there,

i made alterations to the code, whereby i have created to separate tables for light and temperature, which reads two different files, although both the tables and data gets displayed, each table has two addtional empty rows printed to it, like below. How do I stop this from happening??


Expand|Select|Wrap|Line Numbers
  1.  
  2. Todays Temperature 
  3.  
  4. Outlook: image1.gif 
  5. Temperature: Todays temperature is: 90 degrees 
  6. Temperature : 
  7. Temperature :
  8.  
  9. Todays Light Intensity 
  10.  
  11. Outlook: image2.gif 
  12. Light: Todays temperature is: 90 degrees 
  13. Light : 
  14. Light :
  15.  
  16.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.util.*,java.io.*" %>
  3.  
  4.  
  5.  
  6. <html>
  7. <head>
  8.  
  9. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  10.  
  11. </head>
  12.  
  13. <body>
  14.  
  15. <hr></hr>
  16.  
  17. <center>
  18.  
  19. <h1> 
  20.  
  21. Weather Forecast</h1>
  22. <br><br>
  23.  
  24.  
  25. <a href="test.html"> Local Five day forecast </a>
  26.  
  27. <br><br><br><br>
  28.  
  29. <table border=1 cellpadding=5 cellspacing=0 width="50%">
  30. <tr><th colspan=2>Todays Temperature </th></tr>
  31.  
  32. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  33.  
  34.  
  35. <% 
  36.  
  37. String tempString;
  38. BufferedReader dataFile1 = null;
  39. try {
  40. //String[] temp = {"Temperature", "Light"};
  41. int recCount1 = 0;
  42.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  43.      dataFile1 = new BufferedReader(dFile1);
  44.     tempString = dataFile1.readLine();
  45.     while(tempString != null){
  46. %>
  47.  
  48.  
  49.  
  50. <tr ><th>Temperature</th><td><%=tempString%></td> </tr>
  51.  
  52.  
  53.  
  54.  
  55. <%    
  56.  
  57.      recCount1++;
  58.      //out.println(valString);
  59.      tempString = dataFile1.readLine();
  60.     }
  61. }
  62. catch (FileNotFoundException e) {
  63. System.err.println("FileStreamsTest: " + e);
  64. }
  65. catch(IOException iOE) {
  66. iOE.printStackTrace();
  67. }
  68. finally {
  69. dataFile1.close();
  70. }
  71.  
  72. %>
  73.  
  74. </table>
  75. <br><br><br>
  76.  
  77.  
  78. <table border=1 cellpadding=5 cellspacing=0 width="50%">
  79. <tr><th colspan=2>Todays Light Intensity</th></tr>
  80.  
  81. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  82.  
  83.  
  84. <% 
  85.  
  86. String valString;
  87. BufferedReader dataFile = null;
  88. try {
  89. //String[] temp = {"Temperature", "Light"};
  90. int recCount = 0;
  91.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  92.      dataFile = new BufferedReader(dFile);
  93.     valString = dataFile.readLine();
  94.     while(valString != null){
  95. %>
  96.  
  97.  
  98.  
  99.  
  100.  
  101. <tr><th>Light</th>    <td><%=valString%></td> </tr>
  102.  
  103.  
  104. <%    
  105.  
  106.      recCount++;
  107.      //out.println(valString);
  108.      valString = dataFile.readLine();
  109.     }
  110. }
  111. catch (FileNotFoundException e) {
  112. System.err.println("FileStreamsTest: " + e);
  113. }
  114. catch(IOException iOE) {
  115. iOE.printStackTrace();
  116. }
  117. finally {
  118. dataFile.close();
  119. }
  120.  
  121. %>
  122. </table>
  123.  
  124.  
  125. <br><br><br><br><br><br><br><br><br>
  126.  
  127. <hr></hr>
  128.  
  129. </body>
  130. </html>
  131.  
  132.  
You could exclude the empty string with

Expand|Select|Wrap|Line Numbers
  1.  
  2. while(tempString != null){
  3.    if(!tempString.equals("") ) {
  4.      //..........
Feb 22 '07 #5
Naha
41 New Member
I added the if statement but the page does not load up.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <%@ page import="java.util.*,java.io.*" %>
  4.  
  5.  
  6.  
  7. <html>
  8. <head>
  9.  
  10. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  11.  
  12. </head>
  13.  
  14. <body>
  15.  
  16. <hr></hr>
  17.  
  18. <center>
  19.  
  20. <h1> 
  21.  
  22.  Weather Forecast</h1>
  23.  <br>
  24.  
  25.  
  26.  <a href="test.html"> Local Five day forecast </a>
  27.  
  28.  <br><br>
  29.  
  30.  <table border=1   cellpadding=5 cellspacing=0 width="50%">
  31. <tr><th colspan=2>Todays Temperature </th></tr>
  32.  
  33. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  34.  
  35.  
  36.  <% 
  37.  
  38.   String tempString;
  39.   BufferedReader dataFile1 = null;
  40.    try {
  41.    //String[] temp = {"Temperature", "Light"};
  42.    int recCount1 = 0;
  43.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  44.        dataFile1 = new BufferedReader(dFile1);
  45.     tempString = dataFile1.readLine();
  46.     while(tempString != null){
  47.     if(!tempString.equals("") ) {
  48.  
  49. %>
  50.  
  51.  
  52.  
  53.  <tr ><th>Temperature (Degree Celsius) :</th><td><%=tempString%></td> </tr>
  54.  
  55.  
  56.  
  57.  
  58. <%    
  59.  
  60.      recCount1++;
  61.      //out.println(valString);
  62.      tempString = dataFile1.readLine();
  63.     }}
  64.    }
  65.    catch (FileNotFoundException e) {
  66.    System.err.println("FileStreamsTest: " + e);
  67.   }
  68.   catch(IOException iOE) {
  69.    iOE.printStackTrace();
  70.   }
  71.   finally {
  72.    dataFile1.close();
  73.   }
  74.  
  75. %>
  76.  
  77. </table>
  78. <br><br><br>
  79.  
  80.  
  81. <table border=1   cellpadding=5 cellspacing=0 width="50%">
  82. <tr><th colspan=2>Todays Light Intensity</th></tr>
  83.  
  84. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  85.  
  86.  
  87.  <% 
  88.  
  89.   String valString;
  90.   BufferedReader dataFile = null;
  91.    try {
  92.    //String[] temp = {"Temperature", "Light"};
  93.    int recCount = 0;
  94.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  95.        dataFile = new BufferedReader(dFile);
  96.     valString = dataFile.readLine();
  97.     while(valString != null){
  98.     if(!tempString.equals("") ) {
  99. %>
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  <tr><th>Light Intensity (Lux) :</th>    <td><%=valString%></td> </tr>
  106.  
  107.  
  108. <%    
  109.  
  110.      recCount++;
  111.      //out.println(valString);
  112.      valString = dataFile.readLine();
  113.     }}
  114.    }
  115.    catch (FileNotFoundException e) {
  116.    System.err.println("FileStreamsTest: " + e);
  117.   }
  118.   catch(IOException iOE) {
  119.    iOE.printStackTrace();
  120.   }
  121.   finally {
  122.    dataFile.close();
  123.   }
  124.  
  125. %>
  126.  </table>
  127.  
  128.  
  129. <br>
  130.  
  131. <hr></hr>
  132.  
  133. </body>
  134. </html>
  135.  
  136.  
Feb 22 '07 #6
r035198x
13,262 MVP
I added the if statement but the page does not load up.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <%@ page import="java.util.*,java.io.*" %>
  4.  
  5.  
  6.  
  7. <html>
  8. <head>
  9.  
  10. <LINK REL="stylesheet" TYPE="text/css" HREF="stylesheet1.css">
  11.  
  12. </head>
  13.  
  14. <body>
  15.  
  16. <hr></hr>
  17.  
  18. <center>
  19.  
  20. <h1> 
  21.  
  22. Weather Forecast</h1>
  23. <br>
  24.  
  25.  
  26. <a href="test.html"> Local Five day forecast </a>
  27.  
  28. <br><br>
  29.  
  30. <table border=1 cellpadding=5 cellspacing=0 width="50%">
  31. <tr><th colspan=2>Todays Temperature </th></tr>
  32.  
  33. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  34.  
  35.  
  36. <% 
  37.  
  38. String tempString;
  39. BufferedReader dataFile1 = null;
  40. try {
  41. //String[] temp = {"Temperature", "Light"};
  42. int recCount1 = 0;
  43.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  44.      dataFile1 = new BufferedReader(dFile1);
  45.     tempString = dataFile1.readLine();
  46.     while(tempString != null){
  47.     if(!tempString.equals("") ) {
  48.  
  49. %>
  50.  
  51.  
  52.  
  53. <tr ><th>Temperature (Degree Celsius) :</th><td><%=tempString%></td> </tr>
  54.  
  55.  
  56.  
  57.  
  58. <%    
  59.  
  60.      recCount1++;
  61.      //out.println(valString);
  62.      tempString = dataFile1.readLine();
  63.     }}
  64. }
  65. catch (FileNotFoundException e) {
  66. System.err.println("FileStreamsTest: " + e);
  67. }
  68. catch(IOException iOE) {
  69. iOE.printStackTrace();
  70. }
  71. finally {
  72. dataFile1.close();
  73. }
  74.  
  75. %>
  76.  
  77. </table>
  78. <br><br><br>
  79.  
  80.  
  81. <table border=1 cellpadding=5 cellspacing=0 width="50%">
  82. <tr><th colspan=2>Todays Light Intensity</th></tr>
  83.  
  84. <tr ><th>Outlook</th> <TD><center><IMG SRC="sunny.gif" ALT="S" BORDER=0 WIDTH=100 HEIGHT=100 ></center></TD></tr>
  85.  
  86.  
  87. <% 
  88.  
  89. String valString;
  90. BufferedReader dataFile = null;
  91. try {
  92. //String[] temp = {"Temperature", "Light"};
  93. int recCount = 0;
  94.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  95.      dataFile = new BufferedReader(dFile);
  96.     valString = dataFile.readLine();
  97.     while(valString != null){
  98.     if(!tempString.equals("") ) {
  99. %>
  100.  
  101.  
  102.  
  103.  
  104.  
  105. <tr><th>Light Intensity (Lux) :</th>    <td><%=valString%></td> </tr>
  106.  
  107.  
  108. <%    
  109.  
  110.      recCount++;
  111.      //out.println(valString);
  112.      valString = dataFile.readLine();
  113.     }}
  114. }
  115. catch (FileNotFoundException e) {
  116. System.err.println("FileStreamsTest: " + e);
  117. }
  118. catch(IOException iOE) {
  119. iOE.printStackTrace();
  120. }
  121. finally {
  122. dataFile.close();
  123. }
  124.  
  125. %>
  126. </table>
  127.  
  128.  
  129. <br>
  130.  
  131. <hr></hr>
  132.  
  133. </body>
  134. </html>
  135.  
  136.  
You mean nothing shows? Any error messages, exceptions etc
Feb 22 '07 #7
Naha
41 New Member
no nothing, its like the screens frozen.
Feb 22 '07 #8
r035198x
13,262 MVP
no nothing, its like the screens frozen.
It must be something else then. That if statement does not cause the computer to freeze.
Feb 22 '07 #9
Naha
41 New Member
The computer does not freeze, but it does not load up, however when i take the if statement away it loads up fine.
Feb 22 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2212
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to python-help, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the helpers. The most comprehensive overview of python.org help resources is at ...
4
3353
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how to do that? Thanks. Sarir
0
568
by: tbatwork828 | last post by:
If you were like me trying to figure out how to launch context sensitive help topic by the context id, here is the link: http://weblogs.asp.net/kencox/archive/2004/09/12/228349.aspx and if link doesn't work, basically here is the article: An Exploration Into Launching Context-Sensitive HTML Help with Topic IDs in VB.NET I spent this evening investigating the HTML Help API as implemented in
3
3362
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
27
2820
by: Bruce Dodds | last post by:
I recently started using Access 2003 for the first time. I wanted to pass on some comments about the Help system to Access MVPs who frequent this board. I'm doing this in the hope that some of what I say may be passed on to Microsoft. Microsoft has implemented a combination local and web based help system in Access 2003. The local Help installed on your hard drive is fast, but the content is abbreviated. For really useful help you have...
5
3382
by: Steve Teeples | last post by:
Can someone point me to a document that clearly identifies the steps of creating a good help system for an application? I have a test tool that I'd like to add help to so that others will know how to use it. -- Steve
0
1509
by: Yabedabe | last post by:
Hello there, I have a strange problem (possible bug?) to display two HTML Help files at the same time. To reproduce this problem. Create a new VB.Net solution. Place two buttons on the form. Create two button_click events with the following code in it For button1 Help.ShowHelpIndex(Me, "C:\Temp\File1 mspaint.chm")
10
3364
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
5
1511
by: PaulS | last post by:
new to Fedora7, typed python in interactive interpreter, then help(). Then modules to get a list of modules. Then module name to get info on a module but no help file. What is the help file name? Is there an environmental variable I have to set? Thanks, Paul
6
2875
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.