Results 1 to 3 of 3

Thread: Enabling Spring in ugly JSPs

  1. #1
    Join Date
    Apr 2005
    Posts
    23

    Default 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. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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);

  3. #3
    Join Date
    Apr 2005
    Posts
    23

    Default 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!

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 1
    Last Post: May 4th, 2005, 02:43 PM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •