473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help-My table does not get displayed

41
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 1549
Naha
41
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 8TB
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
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 8TB
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
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 8TB
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
no nothing, its like the screens frozen.
Feb 22 '07 #8
r035198x
13,262 8TB
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
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
abctech
157 100+
The computer does not freeze, but it does not load up, however when i take the if statement away it loads up fine.
Expand|Select|Wrap|Line Numbers
  1. <%int recCount = 0;
  2.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  3.     dataFile = new BufferedReader(dFile);
  4.     valString = dataFile.readLine();
  5.     while(valString != null){
  6.     if(!tempString.equals("") ) {
  7. %>
Here shouldn' t you be saying if(valString.equals("")) ?
Feb 22 '07 #11
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. <%int recCount = 0;
  2.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  3.     dataFile = new BufferedReader(dFile);
  4.     valString = dataFile.readLine();
  5.     while(valString != null){
  6.     if(!tempString.equals("") ) {
  7. %>
Here shouldn' t you be saying if(valString.equals("")) ?
Indeed, abtech. That should have been

Expand|Select|Wrap|Line Numbers
  1.  if(!valString.equals("") ) {
I wonder where I got tempString from.
Feb 23 '07 #12
abctech
157 100+
Indeed, abtech. That should have been
Expand|Select|Wrap|Line Numbers
  1.  if(!valString.equals("") ) {
I wonder where I got tempString from.
There were 2 different files to work with. Naha's code for the first file was -
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3.   String tempString;
  4.   BufferedReader dataFile1 = null;
  5.    try {
  6.    //String[] temp = {"Temperature", "Light"};
  7.    int recCount1 = 0;
  8.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  9.        dataFile1 = new BufferedReader(dFile1);
  10.     tempString = dataFile1.readLine();
  11.     while(tempString!= null){
  12.     if(!tempString.equals("") ) {
  13.  
  14. %>
Here he made the appropriate change as you suggested, but must have missed it somehow in the code for the second file -
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3.   String valString;
  4.   BufferedReader dataFile = null;
  5.    try {
  6.    //String[] temp = {"Temperature", "Light"};
  7.    int recCount = 0;
  8.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  9.        dataFile = new BufferedReader(dFile);
  10.     valString = dataFile.readLine();
  11.     while(valString != null){
  12.     if(!tempString.equals("") ) {
  13. %>
Feb 23 '07 #13
r035198x
13,262 8TB
There were 2 different files to work with. Naha's code for the first file was -
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3. String tempString;
  4. BufferedReader dataFile1 = null;
  5. try {
  6. //String[] temp = {"Temperature", "Light"};
  7. int recCount1 = 0;
  8.     FileReader dFile1 = new FileReader("w:/www/DataFile1.txt");
  9.      dataFile1 = new BufferedReader(dFile1);
  10.     tempString = dataFile1.readLine();
  11.     while(tempString!= null){
  12.     if(!tempString.equals("") ) {
  13.  
  14. %>
Here he made the appropriate change as you suggested, but must have missed it somehow in the code for the second file -
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.  
  3. String valString;
  4. BufferedReader dataFile = null;
  5. try {
  6. //String[] temp = {"Temperature", "Light"};
  7. int recCount = 0;
  8.     FileReader dFile = new FileReader("w:/www/DataFile2.txt");
  9.      dataFile = new BufferedReader(dFile);
  10.     valString = dataFile.readLine();
  11.     while(valString != null){
  12.     if(!tempString.equals("") ) {
  13. %>
The program should have given a nullpointer exception because then tempString was null in the secong if statement. I wonder why he/she failed to see that on the stacktrace
Feb 23 '07 #14
abctech
157 100+
The program should have given a nullpointer exception because then tempString was null in the secong if statement. I wonder why he/she failed to see that on the stacktrace
Indeed, it did throw a nullpointer exception , thats how I located the error.
Feb 23 '07 #15
r035198x
13,262 8TB
no nothing, its like the screens frozen.
I'm not running it on my computer so when Naha said the above after I had asked if there were any exceptions, I had really become stumped.
Feb 23 '07 #16

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

Similar topics

0
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...
4
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...
0
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...
3
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...
27
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...
5
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...
0
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....
10
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...
5
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...
6
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
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.