wood burning stoves 2.0*
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get relative path from ServletContextListener class
 
Similar Threads
Dispatcher Relative Path
Load image in an Applet
problem with MyClass.class.getResource()
getRequestDispatcher
Question regarding, Scala IO and reading a file