• Post Reply Bookmark Topic Watch Topic
  • New Topic

getRealPath() method

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

In init() method, I get the path like this:

ServletContext context = config.getServletContext();
String path = context.getRealPath("/");

In doGet(), when I try to display it - out.println(path) - it shows null

do I miss something here? path is String (class variable)

thanks all
anthony
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,

path may be a class variable, but by putting String in front of it like that in the method you're declaring it as local, so you're not assigning the value to the class variable. Otherwise it'll work fine.

Jules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!