wood burning stoves 2.0*
The moose likes JSP and the fly likes Creating file and writing errors to it, not successful Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Creating file and writing errors to it, not successful" Watch "Creating file and writing errors to it, not successful" New topic
Author

Creating file and writing errors to it, not successful

Sean Cormican
Greenhorn

Joined: Aug 25, 2011
Posts: 8
I tried using the code within a java class to test it and it works fine but it will not work correctly and issues no warning when used inside a JSP am I missing something
the file itself is not even created ? e.g. output.txt


username bug bugCode bugError
are all variables containing information from the database

Does anybody have any thoughts ?

Thanks in advance !
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Why on earth would you move working code out of a Java class and into a JSP?

Putting Java code into a JSP is a very poor practice that has been discredited for 10 years now. Leave the code in the Java class where it belongs.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

You need to understand how JSPs are compiled and executed.
For example, Logout.jsp:

Becomes; Logout_jsp.java (in <server>/work/jboss.web/localhost/_/org/apache/jsp

Big difference eh? Since you have no folder or directory on your new FileWriter("output.txt", true) code, where do you think the file is going to be created at run-time?

JSPs do no execute at all, not ever. They are converted at run-time to pure Java in a temporary location (depending on web server and run from there).

Pat.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating file and writing errors to it, not successful
 
Similar Threads
Writing a .csv file from.mdb file with Jackcess
Text Formating and FileWriter
Sending SMS
Stuck with readline and acknowledgement processing.
Writing to a file