Results 1 to 5 of 5

Thread: How to get URL of a resource in AppCtxt?

  1. #1

    Default 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. #2
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    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
    Sami

  3. #3

    Default

    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?

  4. #4

    Default

    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

  5. #5
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    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.
    Sami

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •