Hi,

>I was just reading this thread from August.  Unfortunately, I *think* I
>need a custom stream handler factory as I want to be able to hack about
>with some of the URLs before they get a chance to open.

That's an unfortunate requirement.  It's tricky at best.  We discussed
this back as jar as June: see the thread and accompanying Bugzilla issue
at http://issues.apache.org/bugzilla/show_bug.cgi?id=29631.  We decided
not to allow customization of this for 5.0.x, as too much would be
involved.

Now that 5.5 is stable and improving, the above item certainly won't be
done for 5.0, but might be an interesting discussion point for 5.5.
However, before even opening such a discussion, we should consider
alternatives for your use-case.


>Here's the
>scenario:
>
>- I have a directory containing a resource - call it X.xml - and a JSP
-
>call it displayX.jsp.
>
>- I want to read X.xml from code within the JSP.  What are the ways,
>accoring to the JSP and servlet specs, that I can do this?

Numerous ways, with two good ones coming to mind and two bad ones.

Good:
URL xUrl = getServletContext().getResource("/path/to/x.xml");
URL xUrl = getClass().getResource("/path/to/x.xml/on/classpath");

Bad:
URL xUrl = new File("/path/to/x.xml").toURI().toURL();
URL xUrl = getServletContext().getRealPath("/path/to/x.xml");

(Bad listed as such because they break inside a packed WAR file and
limit portability).

You would then parse from a URL using the JAXP APIs, that's fairly
standard.  Or maybe another higher-level tool like JDOM if that's your
cup of tea.

But note in all these ways the scheme of the URL doesn't matter, it's up
to the server to resolve them.  The two Good ones above would be jndi:/
URLs.

>I need to intercept all of those ways, because that file X.xml might be
>somewhere else completely and only need to appear to the webapp to be
in
>that directory.

If the container can't resolve it using getResource, that means your
webapp is not compliant to the Servlet Spec.

>For bonus points, the JSP itself might be in a
>different place from its requested URL (I have a filter that remaps
>paths on requests, as suggested by Steve Kirk in response to an earlier
>plea for help on this list).

That's irrelevant.  It won't be the calling JSP itself resolving the
resource path.  Your resource resolution would be relative to either
your docBase or your classpath, neither of which are affected by where
your JSP is.

Yoav



This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, proprietary 
and/or privileged.  This e-mail is intended only for the individual(s) to whom 
it is addressed, and may not be saved, copied, printed, disclosed or used by 
anyone else.  If you are not the(an) intended recipient, please immediately 
delete this e-mail from your computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to