Due to the complexity of the question and probably vendor specific-ness of the answer, I've altered course and solved the problem.

I wrote my own small taglib to implement the jsp:include functionality. I just need to change the <jsp:include page="/include.html"/> tags into <mylib:include page="/include.html"/>

I'm still interested in knowing if a jsp:include intercept is possible, but I'm not waiting for the answer anymore. If there are any die hard coders/detail-ists out there, let me know if it's even possible without modifying Tomcat itself.

-AAron

From: "AAron nAAs" <[EMAIL PROTECTED]>
Reply-To: "Tomcat Users List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: filter jsp:include servletPath?
Date: Wed, 27 Nov 2002 22:43:28 -0500

Hi all,

This is more clarification about my attempts to automatically intercept and modify a .jsp request's servletPath as well as all the embedded <jsp:include> files.

Examples:
http://blah.com/index.jsp would run <approot>/blah/index.jsp or <approot>/default/index.jsp based on which was first found to exist.
<jsp:include page="/include.html"/> would use <approot>/blah/include.html or <approot>/default/include.html based on which was first found to exist.

I'm choosing a directory for the requested .jsp file based on the hostname specified in the request. I've gotten that to work perfectly by adding a filter to my web.xml file, and wrapping the request object before passing on to the next doFilter(). By overriding the request getServletPath() I can change the servlet or JSP file that gets invoked.

Now I want the jsp:include files to also use an alternate directory. So refering to "/myfile.jsp" in the include would be intercepted and changed to another directory based on the hostname in the original request.

Another view is that I'm creating a "path" to search through to find the requested (or included) file. If the requested file isn't found in the alternate expected directory, it checks in the default directory which will always have the file for request (or include).

The code shows that once the request is filtered, all the jsp:include's are not.

Private method ApplicationDispatcher.invoke() says:
* IMPLEMENTATION NOTE: This implementation assumes
* that no filters are applied to a forwarded or included resource,
* because they were already done for the original request.

Anyway, I'll let you read my original post below for more details on what I've found.

BTW, I've searched long and hard for anyone doing this sort of thing. But, I'm certainly open to the embarassment of "Oh, just do this" if I've missed the obvious :-)

Thanks,
-AAron

My original post:

I'm trying to intercept a jsp:include so that I can adjust the requested file (ie: "/include.html") to a different directory/file (ie: "/otherdir/otherfile.html"). If there is an easy way (Filter, Valve, Listener, ...) just let me know. NOTE: I've already created and installed a request filter in my web.xml to filter the initial request, but this doesn't get invoked for jsp:include references.

Current idea:
I want to change the "javax.servlet.include.servlet_path" request attribute so the DefaultServlet.getRelativePath() finds the new file. I can see that the ApplicationDispatcher fires off a list of InstanceEvent's before the DefaultServlet.service() is called.

After days of exploration, I can't figure out how to add to get my InstanceEvent into the InstanceSupport's list (ie: cause a call to the support.addInstanceListener). Is there a configuration that will add my class to my application Context?

Thanks,
-AAron ([EMAIL PROTECTED])


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


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

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


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

Reply via email to