Announcement Announcement Module
Collapse
No announcement yet.
Need to obtain Absolute Filesystem path in Spring Controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to obtain Absolute Filesystem path in Spring Controller

    Hello,

    I am performing an XSLT transformation inside a org.springframework.web.servlet.mvc.Controller class and I've discovered that the controller views the relative root as my drive root, not my webapp's root, and therefore my transformer class is having trouble finding the xslt file that is in my webapp.

    How can I obtain the absolute filesystem path to my webapp from within a spring Controller? In the pure servlet world, you can do this by obtaining the ServletContext and doing a getRealPath() invocation. But since I'm inside a controller, (specifically the handleRequest() method) I don't have access to the ServletContext.

    Help! How can this be done?

  • #2
    Originally posted by brado77
    But since I'm inside a controller, (specifically the handleRequest() method) I don't have access to the ServletContext.
    Yes you do. What's wrong with this?

    Code:
    request.getSession().getServletContext();
    Bob

    Comment


    • #3
      My brain....that's the problem. :-)

      Thanks, my brain shorted out....

      B

      Comment


      • #4
        TMTOWTDI, you can also implement ServletContextAware in your controllers, for example. Of course, that only works inside a WebApplicationContext.

        Comment

        Working...
        X