| | |
program
Thread Solved |
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Aug 2007
Posts: 238
Reputation:
Solved Threads: 0
Java Syntax (Toggle Plain Text)
/* * FileBean.java * * Created on September 1, 2007, 10:13 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package exampleprojects; /* * FileBean.java * * Created on August 30, 2007, 6:58 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ import java.io.*; /** * * @author fpcampus */ public class FileBean { private String file; /** Creates a new instance of FileBean */ public FileBean() { } public void setFile(String file){ this.file=file; } public void setData(String data){ FileWriter fw= null; PrintWriter pw= null; try{ fw= new FileWriter(file, true); pw= new PrintWriter(fw); pw.println(data); pw.flush(); pw.close(); fw.close(); }catch(Exception exc){} } public String getData(){ FileReader fr= null; BufferedReader br= null; String line=" "; String tempS=" "; try{ fr= new FileReader(file); br= new BufferedReader(fr); line = br.readLine(); while(line!=null){ tempS= tempS + line + "<br>"; line=br.readLine(); } }catch(Exception exc){} return tempS; } }
Java Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Account information</title> </head> <body> <h2>Account information</h2> <form action="interface.jsp" method="post"> <select name="topic"> <option value="none">Select a topic <option value="JSP">Java Server Pages <option value="Tomcat">Tomcat Server <option value="Java">Java Programming </select><br><br> <input type="submit" name="view" value="View bulletin"><br> <input type="submit" name="post" value="Post bulletin/"> </form> </body> </html>
Java Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Account information</title> </head> workspace/ExampleProjects/build/classes/exampleprojects <body> <jsp:useBean id="fileBean" class="exampleprojects.FileBean"/> <% String topic =request.getParameter("topic"); String vPath ="exampleprojects/"+topic+".txt"; String filePath=getServletConfig().getServletContext().getRealPath(vPath); if(topic.equals("none")){ %> Please Select a topic. <%}else{%> <jsp:setProperty name="fileBean" property="file" value="<%= filePath %>"/> <% if(request.getParameter("view")!= null){ %> <jsp:getProperty name="fileBean" property="data"/> <%}%> <% if(request.getParameter("post") != null){ %> <h2>Account Information</h2> <form action="interface.jsp" method="post"> <TextArea> name=message cols=25 rows=5></TextArea> <input type=hidden name=topic value="<%= topic%>"><br> <input type =submit name=addBulletin value="post bulletin"> </form> <%>}%> <% if(request.getParameter("addBulletin") !=null && !request.getParameter("message").equals(" ")){ %> <h2>Bulletin Saved!</h2> <jsp:setProperty name="fileBean" property="data" param="message"/> <jsp:setProperty name="fileBean" property="data" value="----------------------------------"/> <% } %> <% } %> <br><br> <a href="interface.html">Return to main Page</a> </body> </html>
Java Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <title>James Stephen Howerton Advanced Java</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="images/mm_health_nutr.css" type="text/css" /> <script language="JavaScript" type="text/javascript"> //--------------- LOCALIZEABLE GLOBALS --------------- var d=new Date(); var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); //Ensure correct for language. English is "January 1, 2004" var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear(); //--------------- END LOCALIZEABLE --------------- </script> <style type="text/css"> <!-- a:link { color: #009900; } a:visited { color: #999999; } a:hover { color: #009999; } a:active { color: #FF0000; } a { font-size: 14px; } .style1 {font-size: 12px} --> </style></head> <body bgcolor="#F4FFE4"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#D5EDB3"> <td width="382" colspan="2" rowspan="2"><img src="images/header1.jpg" alt="advanced java programs." width="382" height="101" /></td> <td width="378" height="50" id="logo" valign="bottom" align="center" nowrap="nowrap">James Stephen Howerton </td> <td width="100%"> </td> </tr> <tr bgcolor="#D5EDB3"> <td height="51" id="tagline" valign="top" align="center">SLCC Forest Park Fall 2006 </td> <td width="100%"> </td> </tr> <tr> <td colspan="4" bgcolor="#5C743D"><img src="images/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td> </tr> <tr> <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> </tr> <tr bgcolor="#99CC66"> <td> </td> <td colspan="3" id="dateformat" height="20">Today Is :: <script language="JavaScript" type="text/javascript"> document.write(TODAY); </script> </td> </tr> <tr> <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> </tr> <tr> <td colspan="4" bgcolor="#5C743D"><img src="images/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td> </tr> <tr> <td width="40"> </td> <td colspan="2" valign="top"> <br /> <br /> <table width="610" border="2" align="center" cellpadding="2" cellspacing="0"> <tr> <td colspan="7" bgcolor="#00FF00" class="pageName"><div align="center">Completed Programs </div></td> </tr> <tr> <td width="22%" height="110" valign="top"><div align="center"><a href="replacement_prog_1.html">Replacement Program</a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href="Celsius Into Fahrenheit_proj_1.htm">Celsius Into Fahrenheit</a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href="OnlineProduceStand.html">Online Produce Stand </a> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href="guest_book.jsp">Guest Book</a></div></td> </tr> <tr> <td class="detailText" valign="top" nowrap="nowrap"><a href="library_lookup.html"></a>Program one /part one <br /></td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program one/part two <br /></td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program two <br></td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program Three/part one</td> </tr> <tr> <td colspan="7"> </td> </tr> <tr> <td height="110" valign="top"><div align="center"><span class="detailText"><a href="xyz.html">XYZ Company</a></span></div></td> <td valign="top"> </td> <td height="110" valign="top"><div align="center"><span class="detailText"><a href="musicMagazineOrderForm.html">Music Magazine Order Form</a></span></div></td> <td valign="top"> </td> <td height="110" valign="top"><div align="center"><span class="detailText"><a href="javascript:;">update file</a></span></div></td> <td valign="top"> </td> <td height="110" valign="top"><div align="center"><span class="detailText"><a href="quiz.html">Quiz</a></span></div></td> </tr> <tr> <td class="detailText" valign="top" nowrap="nowrap">Program three/part two</td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program four</td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program five</td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap">Program six</td> </tr> <tr> <td width="22%" height="110" valign="top"><div align="center"><a href="dbconnection.jsp"> dbconnection.jsp?</a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""></a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""> </a> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""></a></div></td> </tr> <tr> <td width="22%" height="110" valign="top"><div align="center"><a href="interface.html"> interface.html?</a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""></a> </div></td> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""> </a> <td valign="top"> </td> <td width="22%" height="110" valign="top"><div align="center"><a href=""></a></div></td> </tr> <tr> <td class="detailText" valign="top" nowrap="nowrap">Program seven</td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap"></td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap"></td> <td> </td> <td class="detailText" valign="top" nowrap="nowrap"></td> </tr> <tr> <td colspan="7"><div align="center" class="style1"><a href="mailto:ceyesumma@hotmail.com">Contact</a><br /> Revised October 26, 2006 </div></td> </tr> </table> </td> <td width="100%"> </td> </tr> <tr> <td width="40"> </td> <td width="342"> </td> <td width="378"> </td> <td width="100%"> </td> </tr> </table> </body> </html>
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
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
I found some extra bracklets in your JSP file and here is updated version
Java Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Account information</title> </head> <body> <jsp:useBean id="fileBean" class="exampleprojects.FileBean"/> <% String topic =request.getParameter("topic"); String vPath ="exampleprojects/"+topic+".txt"; String filePath=getServletConfig().getServletContext().getRealPath(vPath); if(topic.equals("none")) {%> Please Select a topic. <%} else {%> <jsp:setProperty name="fileBean" property="file" value="<%= filePath %>"/> <% if(request.getParameter("view")!= null) {%> <jsp:getProperty name="fileBean" property="data"/> <%} if(request.getParameter("post") != null) {%> <h2>Account Information</h2> <form action="interface.jsp" method="post"> <TextArea name=message cols=25 rows=5></TextArea> <input type=hidden name=topic value="<%= topic%>"><br> <input type =submit name=addBulletin value="post bulletin"> </form> <%} if(request.getParameter("addBulletin") !=null && !request.getParameter("message").equals("")) {%> <h2>Bulletin Saved!</h2> <jsp:setProperty name="fileBean" property="data" param="message"/> <jsp:setProperty name="fileBean" property="data" value="----------------------------------"/> <% } } %> <br><br> <a href="interface.html">Return to main Page</a> </body> </html>
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the Java Forum
- Previous Thread: error
- Next Thread: GUI buttons Inventory Part 5
| Thread Tools | Search this Thread |
6 @param actuate android api applet application arc array arrays automation balls binary bluetooth bold business byte c++ chat class client code codesnippet collections compare component coordinates database defaultmethod detection doctype dragging ebook eclipse educational error file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework hql html ide ideas image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans newbie nextline parameter php pong problem program programming project recursion recursive scanner sell server set sms sort sql string sun swing swt terminal threads tree web websites windows






