Re: Application-aware JSPs?
"Jeff K. Hoffman" <[email protected]> Mon, 10 May 2004 15:00:51 -0400
| Newsgroups | gmane.linux.redhat.ccm.general |
|---|---|
| Message-ID | <[email protected]> |
Daniel P. Berrange wrote: > It somewhat depends on how (what URL) you request the JSP. If > for example you request it via the mounted application, eg > > /ccm/myapp/index.xml > > Then this initial request will be served by DispatcherServlet. > This delegates most of its logic to BaseDispatcher, which is > what does the resolution of /ccm/myapp into an instance of > the com.example.MyApp class. Having resolved an application, > it sets up the WebContext & forwards onto the servlet defined > by 'getServletPath' method of MyApp. ie the ApplicationFileServlet. > Now, the ApplicationFileServlet forwards onto a concrete JSP > file on disk, eg /templates/ccm-myapp/index.jsp > > So, the bottom line is that if the requests for your JSP file > come in via /ccm/myapp/... the WebContext will be populated with > the correct Application instance before your JSP is invoked. > > The only situation in which Web.getContext().getApplication() can > return null, is if you are requesting the JSP directly with its > concrete URL, > > ie, /templates/ccm-myapp/index.jsp > > instead of the correct > > /ccm/myapp/index.xml Can you think of any other cases in which Web.getContext().getApplication() can return null, even when accessed through the DispatcherServlet? All of the pieces you outline above seem to be in place in my environment. When I make a request, I see log output somewhat like the following (from memory, since I'm not on my R&D box, now): invocation: /ccm/myapp/index.jsp (contextPath: /ccm, servletPath: /myapp/index.jsp, servlet:ccm-dispatcher, ...) [CCM's dispatcher locates myapp, then dispatches to it...] invocation: /myapp/files/index.jsp (contextPath: /myapp, servletPath: /files/index.jsp, servlet: files, ...) realPath: /templates/myapp/myapp1/index.jsp -> /var/ccm-devel/web/myuser/webapps/myapp/templates/myapp/myapp1/index.jsp realPath: /templates/myapp/index.jsp -> /var/ccm-devel/web/myuser/webapps/myapp/templates/myapp/index.jsp jsp: init() ... And then my JSP displays, with a 'null' as its output. I know CCM is finding my application, since changes to my app's getContextPath() and getServletPath() methods affect runtime behavior. Could my mis-use of BaseJSP be screwing things up? In other words, since BaseJSP is not required when using DispatcherServlet/BaseDispatcher, could its use in this context be mucking with the web context machinery? > The BaseJSP class is intended for JSPs which want to bypass > the DispatcherServlet/BaseDispatcher stuff altogether. As > such it only sets up the current Party & Locale, but none of > the Application context. If your JSPs are going via the > BaseDispatcher there is no need to have 'extends=BaseJSP' > tag since this stuff will have already been setup for you. Ahhhh. This was not obvious to me, from any of the doc/javadoc I've read thus far. Thanks! > Creating a BaseApplicationJSP for situations where you want > to use the Application objects framework, but not BaseDispatcher > smacks of wheel re-invention to me. Since your BaseApplicationJSP > would basically end up duplicating all of what BaseDispatcher does > you might as well take advantage of the existing BaseDispatcher > stuff in the first place. Indeed. I felt like I was doing something wrong, but couldn't figure out where I was going wrong. > Da. --Jeff -- |.. Jeff Hoffman - [email protected] - +1 (704) 849-0731 x108 ..| |.. Chief Technology Officer - Planned Giving Design Center ..| |.. 10800 Independence Pointe Parkway, Suite D, Matthews, NC, 28105 ..| -- Redhat-ccm-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/redhat-ccm-list Archives: https://www.redhat.com/pipermail/redhat-ccm-list/