From: Keats K. <ke...@xa...> - 2005-05-24 21:08:56
|
Marc Palmer wrote: > Keats Kirsch wrote: > >> I don't like the "smell" of this. Why do you need it anyway? If you >> need the Servlet instance you can just use: >> >> (Servlet)pageContext.getPage() > > > Well: > > 1. is that always guaranteed to be the case That's what the Java docs say. (Although I admit I don't know why they return it as an Object.) > 2. will it definitely be the same classloader as a servlet in the same > webapp, and the same for all JSPs that use the taglib in that webapp? It is the servlet that the page gets compiled into, so it should be fine. > 3. it doesn't work from Spring views. I don't know Spring, but don't you have access to the pageContext anywhere? > 4. it requires a lazy init of the single-instance of WM. I have added > this to the taglib code already, so that it can use ServletContextBroker. Or we could add a new constructor to WM ... >> Anyway, I thought you didn't need to use the Servlet instance if you >> use the new Broker -- wasn't that the point? > > > True, but you were the one who said there should be an option to load > things from the servlet classpath :) > > The problem is you can't get WM to load context tools etc from the > webapp classpath if you don't have the servlet classpath. Unless you add a new getBroker method ... or a new Broker. > I think my solution is neat, in an ugly way :( > > It's a quick and easy way to solve the problem, without violating any > particular rules I know of. > > The other option would be to put the Servlet or its ClassLoader into a > predefined JNDI naming context. Do you like that less, or more ;-( > I don't like either, but I can't say exactly why. It just seems to violate the KISS principle. It's a kludge that doesn't seem necessary. Keats |