0

I have a problem when I try to create a buffer directory for download. I'm using struts 2 ScoreAction.java:

File tempDir = new File(getServlet().getServletContext()
      .getRealPath("temp_file_dir"));

I don't know what problem here, the output allways is:

java.lang.NullPointerException
    at java.io.File.<init>(Unknown Source)
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • looks like the path does not exist. can you try with ("/temp_file_dir"). Also check out this link http://stackoverflow.com/questions/9091491/what-does-the-path-get-from-the-server-by-getrealpath-in-jsp – vikeng21 Dec 26 '14 at 04:16
  • thank,I have try with ("/temp_file_dir") but it's still error. I'm sure that the path is exist. – Bùi Trần Minh Thành Dec 26 '14 at 04:32
  • sorry, my bad. when i try with "/", i type error so, it's not working. I try again and it's working now. thank again @vikeng21 for your help. – Bùi Trần Minh Thành Dec 26 '14 at 04:41
  • I try to do something and i see that in tomcat 5.5 and jdk5.5 the code is OK(no need /). But i am using tomcat 8.0.9 and jdk 8 which need / in file path. so can you explain problem here. I'm just new with strut and java, so I want to know more. – Bùi Trần Minh Thành Dec 26 '14 at 05:03

0 Answers0