File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes tomcat crashes when counting lines in a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "tomcat crashes when counting lines in a text file" Watch "tomcat crashes when counting lines in a text file" New topic
Author

tomcat crashes when counting lines in a text file

Shawn Glisson
Greenhorn

Joined: Feb 13, 2004
Posts: 6
Here is my JSP page....

Here is my public class....

The Problem...
From my JSP page I call the 'public int totalLines()' method in my public class. That method works fine running in a standalone app. but when I attempt to execute it on Tomcat it crashes.
The JSP file takes the filename as a string input. Then it looks for that filename and when it goes into count the total lines in that file it crashes. In fact if I enter in any random string, once it hits that totalLines() method it crashes. I am not validating the string at this point and wont need to when this is complete. But WHY is it crashing when I call that method???
Is Tomcat not finding the file? Where does this text file need to go in relation to my class and JSP files?
Please help...
thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12267
    
    1
You accidently left a System.exit() in the code - calling System.exit prevents Tomcat from processing whatever error/exception message you should be seeing. Probably an IOException because you are using the File method that depends on the "current" directory. In Servlets you can't depend on the "current" directory being any particular thing - therefore, pass a complete path to the FileReader constructor.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: tomcat crashes when counting lines in a text file
 
Similar Threads
jsp & HTML
datas storing twice from servlet to mysql database
reg html tables
Getting Values from a window to parent page
Problem displaying a dynamic table on a JSP....