• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

tomcat crashes when counting lines in a text file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic