Announcement Announcement Module
Collapse
No announcement yet.
Enabling Spring in ugly JSPs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enabling Spring in ugly JSPs

    I'm porting an application to Spring that includes a number of ugly JSPs. By "ugly" I mean that the JSPs are not simply presentation devices, they contain a large amount of java code in scriptlets that implement data access and business logic.

    I realize I will eventually want to replace these sad JSPs for a more modern, proper view technology but for now I just want them ported quickly.

    I need to be able to easily access the ApplicationContext from these JSPs. My thought is to use the custom tag feature that allows me to expose a scripting variable which is the applicationcontext. Then in the JSPs I just include the custom tag and voila -- I can do applicationContext.getBean().

    Am I reinventing the wheel? I looked at Spring's taglib and it does not have what I need. Help me not bark up the wrong tree!

    Thanks!

  • #2
    Take a look here

    You can load your application context in a ContextListener or ContextListenServlet (depending on Servlet engine version) and look up your context using

    Code:
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);

    Comment


    • #3
      Sadly that's not a solution for me

      I'm afraid I'm burned by our archaic J2EE container - WebLogic 6.1.

      I had previously tried your suggested approach. WebLogic 6.1 sadly requires session context objects to be serializable if the hot deploy feature is enabled. I was getting exceptions to this effect when re-deploying servlets or JSPs and my app would fail to operate properly. I'm told that this is not an issue in WL 8.1 BTW.

      I'm not willing to give up hot deploy capability, so I'm currently loading the ApplicationContext using a static method that does this:

      return new ClassPathXmlApplicationContext("applicationContext .xml");

      When I've completed Springifying this app, I should be easily able to run it under Tomcat or WL 8.1, and the serialization problem under WL 6.1 will be a thing of the past. At that time I'll replace that static method with the technique you suggest. For now I'm stuck with it and am having to do some hacks.

      So my original question stands.

      Thanks!

      Comment

      Working...
      X