This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get relative path from ServletContextListener class

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
im using Listener class in my web app , and i need to know the relative path
i know i can use the getServletContext().getRealPath("/") when im using HttpServlet class
but some hoe it seams i can't use it in ServletContextListener class
why ?
Thanks
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meir Yan wrote:Hello all
im using Listener class in my web app , and i need to know the relative path
i know i can use the getServletContext().getRealPath("/") when im using HttpServlet class

For what? This doesn't return a relative path at all. It returns an absolute file system path for the given relative web path. So you should already know the relative path!


but some hoe it seams i can't use it in ServletContextListener class

Start reading the javadoc of the class in question. Check the methods. Check the method parameters. Check the javadoc of the class which is used as method parameter. Click your way further to gather information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic