program

Thread Solved
Reply

Join Date: Aug 2007
Posts: 225
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

program

 
0
  #1
Sep 3rd, 2007
I am using a example in a book to build my own program (java server pages) I can not even get the example to run. Is there someone to take a look at the program? (netbeans package)?

Last edited by happygeek; Sep 3rd, 2007 at 6:47 pm. Reason: email snipped, please keep it on-site
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,126
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 472
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: program

 
0
  #2
Sep 3rd, 2007
Please post your code so we can have look. When posting please use code tags [ C O D E ] [/ C O D E] and insert your code between them. Code tags are hidden under hash sign "#"
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 225
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: program

 
0
  #3
Sep 3rd, 2007
  1. /*
  2.  * FileBean.java
  3.  *
  4.  * Created on September 1, 2007, 10:13 PM
  5.  *
  6.  * To change this template, choose Tools | Template Manager
  7.  * and open the template in the editor.
  8.  */
  9.  
  10. package exampleprojects;
  11. /*
  12.  * FileBean.java
  13.  *
  14.  * Created on August 30, 2007, 6:58 PM
  15.  *
  16.  * To change this template, choose Tools | Template Manager
  17.  * and open the template in the editor.
  18.  */
  19.  
  20.  
  21. import java.io.*;
  22. /**
  23.  *
  24.  * @author fpcampus
  25.  */
  26. public class FileBean {
  27. private String file;
  28. /** Creates a new instance of FileBean */
  29. public FileBean() {
  30. }
  31.  
  32. public void setFile(String file){
  33. this.file=file;
  34. }
  35. public void setData(String data){
  36. FileWriter fw= null;
  37. PrintWriter pw= null;
  38. try{
  39. fw= new FileWriter(file, true);
  40. pw= new PrintWriter(fw);
  41. pw.println(data);
  42. pw.flush();
  43. pw.close();
  44. fw.close();
  45. }catch(Exception exc){}
  46. }
  47. public String getData(){
  48. FileReader fr= null;
  49. BufferedReader br= null;
  50. String line=" ";
  51. String tempS=" ";
  52. try{
  53. fr= new FileReader(file);
  54. br= new BufferedReader(fr);
  55. line = br.readLine();
  56. while(line!=null){
  57. tempS= tempS + line + "<br>";
  58. line=br.readLine();
  59. }
  60. }catch(Exception exc){}
  61. return tempS;
  62. }
  63.  
  64. }

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Account information</title>
  6. </head>
  7. <body>
  8. <h2>Account information</h2>
  9. <form action="interface.jsp" method="post">
  10. <select name="topic">
  11. <option value="none">Select a topic
  12. <option value="JSP">Java Server Pages
  13. <option value="Tomcat">Tomcat Server
  14. <option value="Java">Java Programming
  15. </select><br><br>
  16. <input type="submit" name="view" value="View bulletin"><br>
  17. <input type="submit" name="post" value="Post bulletin/">
  18. </form>
  19.  
  20. </body>
  21. </html>
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Account information</title>
  6. </head>
  7. workspace/ExampleProjects/build/classes/exampleprojects
  8. <body>
  9. <jsp:useBean id="fileBean" class="exampleprojects.FileBean"/>
  10. <%
  11. String topic =request.getParameter("topic");
  12. String vPath ="exampleprojects/"+topic+".txt";
  13. String filePath=getServletConfig().getServletContext().getRealPath(vPath);
  14. if(topic.equals("none")){
  15. %>
  16. Please Select a topic.
  17. <%}else{%>
  18. <jsp:setProperty name="fileBean" property="file" value="<%= filePath %>"/>
  19. <%
  20. if(request.getParameter("view")!= null){
  21. %>
  22. <jsp:getProperty name="fileBean" property="data"/>
  23. <%}%>
  24. <%
  25. if(request.getParameter("post") != null){
  26. %>
  27. <h2>Account Information</h2>
  28. <form action="interface.jsp" method="post">
  29. <TextArea> name=message cols=25 rows=5></TextArea>
  30. <input type=hidden name=topic value="<%= topic%>"><br>
  31. <input type =submit name=addBulletin value="post bulletin">
  32. </form>
  33. <%>}%>
  34. <% if(request.getParameter("addBulletin") !=null && !request.getParameter("message").equals(" ")){
  35. %>
  36. <h2>Bulletin Saved!</h2>
  37. <jsp:setProperty name="fileBean" property="data" param="message"/>
  38. <jsp:setProperty name="fileBean" property="data" value="----------------------------------"/>
  39. <% } %>
  40. <% } %>
  41.  
  42. <br><br>
  43. <a href="interface.html">Return to main Page</a>
  44. </body>
  45. </html>
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  4.  
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <!-- DW6 -->
  8. <head>
  9. <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
  10. <title>James Stephen Howerton Advanced Java</title>
  11. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  12. <link rel="stylesheet" href="images/mm_health_nutr.css" type="text/css" />
  13. <script language="JavaScript" type="text/javascript">
  14. //--------------- LOCALIZEABLE GLOBALS ---------------
  15. var d=new Date();
  16. var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
  17. //Ensure correct for language. English is "January 1, 2004"
  18. var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
  19. //--------------- END LOCALIZEABLE ---------------
  20. </script>
  21. <style type="text/css">
  22. <!--
  23. a:link {
  24. color: #009900;
  25. }
  26. a:visited {
  27. color: #999999;
  28. }
  29. a:hover {
  30. color: #009999;
  31. }
  32. a:active {
  33. color: #FF0000;
  34. }
  35. a {
  36. font-size: 14px;
  37. }
  38. .style1 {font-size: 12px}
  39. -->
  40. </style></head>
  41. <body bgcolor="#F4FFE4">
  42. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  43.  
  44. <tr bgcolor="#D5EDB3">
  45. <td width="382" colspan="2" rowspan="2"><img src="images/header1.jpg" alt="advanced java programs." width="382" height="101" /></td>
  46. <td width="378" height="50" id="logo" valign="bottom" align="center" nowrap="nowrap">James Stephen Howerton </td>
  47. <td width="100%">&nbsp;</td>
  48. </tr>
  49.  
  50. <tr bgcolor="#D5EDB3">
  51. <td height="51" id="tagline" valign="top" align="center">SLCC Forest Park Fall 2006 </td>
  52.  
  53. <td width="100%">&nbsp;</td>
  54. </tr>
  55.  
  56. <tr>
  57. <td colspan="4" bgcolor="#5C743D"><img src="images/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  58. </tr>
  59.  
  60. <tr>
  61. <td colspan="4" bgcolor="#99CC66" background="images/mm_dashed_line.gif"><img src="images/mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  62. </tr>
  63.  
  64. <tr bgcolor="#99CC66">
  65. <td>&nbsp;</td>
  66. <td colspan="3" id="dateformat" height="20">Today Is &nbsp;&nbsp;::&nbsp;&nbsp;
  67. <script language="JavaScript" type="text/javascript">
  68. document.write(TODAY); </script> </td>
  69. </tr>
  70.  
  71. <tr>
  72.  
  73. <td colspan="4" bgcolor="#99CC66" background="images/mm_dashed_line.gif"><img src="images/mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  74. </tr>
  75.  
  76. <tr>
  77. <td colspan="4" bgcolor="#5C743D"><img src="images/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  78. </tr>
  79. <tr>
  80. <td width="40">&nbsp;</td>
  81. <td colspan="2" valign="top">&nbsp;<br />
  82.  
  83. &nbsp;<br />
  84. <table width="610" border="2" align="center" cellpadding="2" cellspacing="0">
  85. <tr>
  86. <td colspan="7" bgcolor="#00FF00" class="pageName"><div align="center">Completed Programs </div></td>
  87. </tr>
  88. <tr>
  89. <td width="22%" height="110" valign="top"><div align="center"><a href="replacement_prog_1.html">Replacement Program</a> </div></td>
  90.  
  91. <td valign="top">&nbsp;</td>
  92. <td width="22%" height="110" valign="top"><div align="center"><a href="Celsius Into Fahrenheit_proj_1.htm">Celsius Into Fahrenheit</a> </div></td>
  93. <td valign="top">&nbsp;</td>
  94. <td width="22%" height="110" valign="top"><div align="center"><a href="OnlineProduceStand.html">Online Produce Stand </a>
  95. <td valign="top">&nbsp;</td>
  96. <td width="22%" height="110" valign="top"><div align="center"><a href="guest_book.jsp">Guest Book</a></div></td>
  97. </tr>
  98. <tr>
  99.  
  100. <td class="detailText" valign="top" nowrap="nowrap"><a href="library_lookup.html"></a>Program one /part one <br /></td>
  101. <td>&nbsp;</td>
  102. <td class="detailText" valign="top" nowrap="nowrap">Program one/part two <br /></td>
  103. <td>&nbsp;</td>
  104. <td class="detailText" valign="top" nowrap="nowrap">Program two <br></td>
  105. <td>&nbsp;</td>
  106. <td class="detailText" valign="top" nowrap="nowrap">Program Three/part one</td>
  107.  
  108. </tr>
  109. <tr>
  110. <td colspan="7">&nbsp;</td>
  111. </tr>
  112.  
  113. <tr>
  114. <td height="110" valign="top"><div align="center"><span class="detailText"><a href="xyz.html">XYZ Company</a></span></div></td>
  115. <td valign="top">&nbsp;</td>
  116. <td height="110" valign="top"><div align="center"><span class="detailText"><a href="musicMagazineOrderForm.html">Music Magazine Order Form</a></span></div></td>
  117.  
  118. <td valign="top">&nbsp;</td>
  119. <td height="110" valign="top"><div align="center"><span class="detailText"><a href="javascript:;">update file</a></span></div></td>
  120. <td valign="top">&nbsp;</td>
  121. <td height="110" valign="top"><div align="center"><span class="detailText"><a href="quiz.html">Quiz</a></span></div></td>
  122. </tr>
  123. <tr>
  124. <td class="detailText" valign="top" nowrap="nowrap">Program three/part two</td>
  125. <td>&nbsp;</td>
  126.  
  127. <td class="detailText" valign="top" nowrap="nowrap">Program four</td>
  128. <td>&nbsp;</td>
  129. <td class="detailText" valign="top" nowrap="nowrap">Program five</td>
  130. <td>&nbsp;</td>
  131. <td class="detailText" valign="top" nowrap="nowrap">Program six</td>
  132. </tr>
  133.  
  134. <tr>
  135.  
  136. <td width="22%" height="110" valign="top"><div align="center"><a href="dbconnection.jsp"> dbconnection.jsp?</a> </div></td>
  137. <td valign="top">&nbsp;</td>
  138. <td width="22%" height="110" valign="top"><div align="center"><a href=""></a> </div></td>
  139. <td valign="top">&nbsp;</td>
  140. <td width="22%" height="110" valign="top"><div align="center"><a href=""> </a>
  141. <td valign="top">&nbsp;</td>
  142. <td width="22%" height="110" valign="top"><div align="center"><a href=""></a></div></td>
  143. </tr>
  144. <tr>
  145.  
  146. <td width="22%" height="110" valign="top"><div align="center"><a href="interface.html"> interface.html?</a> </div></td>
  147. <td valign="top">&nbsp;</td>
  148. <td width="22%" height="110" valign="top"><div align="center"><a href=""></a> </div></td>
  149. <td valign="top">&nbsp;</td>
  150. <td width="22%" height="110" valign="top"><div align="center"><a href=""> </a>
  151. <td valign="top">&nbsp;</td>
  152. <td width="22%" height="110" valign="top"><div align="center"><a href=""></a></div></td>
  153. </tr>
  154.  
  155. <tr>
  156. <td class="detailText" valign="top" nowrap="nowrap">Program seven</td>
  157. <td>&nbsp;</td>
  158. <td class="detailText" valign="top" nowrap="nowrap"></td>
  159. <td>&nbsp;</td>
  160. <td class="detailText" valign="top" nowrap="nowrap"></td>
  161. <td>&nbsp;</td>
  162. <td class="detailText" valign="top" nowrap="nowrap"></td>
  163.  
  164. </tr>
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184. <tr>
  185. <td colspan="7"><div align="center" class="style1"><a href="mailto:ceyesumma@hotmail.com">Contact</a><br />
  186. Revised October 26, 2006 </div></td>
  187. </tr>
  188. </table>
  189. </td>
  190. <td width="100%">&nbsp;</td>
  191.  
  192. </tr>
  193.  
  194. <tr>
  195. <td width="40">&nbsp;</td>
  196. <td width="342">&nbsp;</td>
  197. <td width="378">&nbsp;</td>
  198. <td width="100%">&nbsp;</td>
  199. </tr>
  200. </table>
  201. </body>
  202.  
  203. </html>
I have a program I am building but I had to back up to this simple program to try to understand how it should work. Please find inclosed an index.html with a links (interface.html) which should post to interface.jsp that uses file bean. I have to get a working knowledge of writing to a file and systematically go through the file and pull out correct entries. Is it easy to perform this with a simple file writer or should I be working with a random access file? Thank you for your time
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 225
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: program

 
0
  #4
Sep 3rd, 2007
here is a zip file . I used netbeans
Attached Files
File Type: zip ExampleProjects.zip (188.8 KB, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,126
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 472
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: program

 
0
  #5
Sep 3rd, 2007
That is why NetBeans should be used once you learned more about Java and development in Java. NetBeans can be realy confusing...
I found some extra bracklets in your JSP file and here is updated version
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Account information</title>
  6. </head>
  7. <body>
  8. <jsp:useBean id="fileBean" class="exampleprojects.FileBean"/>
  9. <%
  10. String topic =request.getParameter("topic");
  11. String vPath ="exampleprojects/"+topic+".txt";
  12. String filePath=getServletConfig().getServletContext().getRealPath(vPath);
  13. if(topic.equals("none"))
  14. {%>
  15. Please Select a topic.
  16. <%}
  17. else
  18. {%>
  19. <jsp:setProperty name="fileBean" property="file" value="<%= filePath %>"/>
  20. <%
  21. if(request.getParameter("view")!= null)
  22. {%>
  23. <jsp:getProperty name="fileBean" property="data"/>
  24. <%}
  25. if(request.getParameter("post") != null)
  26. {%>
  27. <h2>Account Information</h2>
  28. <form action="interface.jsp" method="post">
  29. <TextArea name=message cols=25 rows=5></TextArea>
  30. <input type=hidden name=topic value="<%= topic%>"><br>
  31. <input type =submit name=addBulletin value="post bulletin">
  32. </form>
  33. <%}
  34. if(request.getParameter("addBulletin") !=null && !request.getParameter("message").equals(""))
  35. {%>
  36. <h2>Bulletin Saved!</h2>
  37. <jsp:setProperty name="fileBean" property="data" param="message"/>
  38. <jsp:setProperty name="fileBean" property="data" value="----------------------------------"/>
  39. <% }
  40. } %>
  41.  
  42. <br><br>
  43. <a href="interface.html">Return to main Page</a>
  44. </body>
  45. </html>
You will now able to navigate from index.html to interface.hml and interface.jsp. However once you create new bulletin and want to view it, it will not be able to display as your bean is dealilng with FileReader that is supposed to create a txt, but I di dnot have time to get it working.

If you will have some problems to run this, just post bellow
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 225
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: program

 
0
  #6
Sep 3rd, 2007
Thanks I apreciate the help very much. I am trying to get past the basics. This web site will be most helpful
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 225
Reputation: ceyesuma is an unknown quantity at this point 
Solved Threads: 0
ceyesuma ceyesuma is offline Offline
Posting Whiz in Training

Re: program

 
0
  #7
Sep 3rd, 2007
Here is the real project (netbeans) that I am working. I am sure there are several errors. If some one has time could you make heads or tails of it?
Attached Files
File Type: zip CreditCard.zip (34.3 KB, 1 views)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC