Announcement Announcement Module
Collapse
No announcement yet.
How to get URL of a resource in AppCtxt? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get URL of a resource in AppCtxt?

    To date, my solution to this has been a custom listener that does all the work programatically, but it looks as if URLEditor might be the correct answer. I just can't find any examples that show me how it might be used.

    I have an xsd located in /xsd of my WAR. I need a URL to that resource to inject into a bean. Is URLEditor the answer?

    Thanks,
    Dave

  • #2
    Hi,

    You could put the xsl in the same package/directory as your bean and then inject its value using

    Code:
    <property name="xsdlocation" value="classpath:com/test/test.xsd"/>
    note the type of the property should be Resource

    Comment


    • #3
      Yes, but I'd like to make the xsd available to other users externally. I don't think I can do that if it's in the classpath "area" of my WAR. Can I?

      Comment


      • #4
        Well, it's a little ugly, but I do have something of a solution.

        Since my ContextLoaderListener has access to the ServletContext, it can easily retrieve the URL of a resource. So, I'm having it get the relative path from the bean, figure out the URL of that path, then put that URL back into the bean.

        I'm sure there's a cleaner way to do this, but it'll work for now.
        Dave

        Comment


        • #5
          Yes, but I'd like to make the xsd available to other users externally. I don't think I can do that if it's in the classpath "area" of my WAR. Can I?
          Hi, If you would want to make the xsd available to external users via HTTP, you can try the following option.

          you could inject the path of the xsd in a bean,

          then you could write a simple abstract controller and inject the above bean into it,
          extract the xsd and put it into the map of the ModelAndView,

          the jsp would then serve it out.

          Comment

          Working...
          X