aspose file tools*
The moose likes Servlets and the fly likes how to get relative path from ServletContextListener class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to get relative path from ServletContextListener class" Watch "how to get relative path from ServletContextListener class" New topic
Author

how to get relative path from ServletContextListener class

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
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

Joined: Oct 08, 2006
Posts: 2458
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to get relative path from ServletContextListener class