0 Replies Latest reply on Feb 18, 2012 3:06 PM by Erhard Siegl

    Dependency Injection from a JSP

    Erhard Siegl Novice

      I have a simple JSP that uses @Inject:

       

      {code}

      <%@ page

                import="javax.naming.*,java.util.*,java.text.SimpleDateFormat,test.*,javax.inject.Inject"%>

      <%!

      @Inject

      private Person pers;

      %>

       

      <html>

      <head><title>Test Inject</title></head>

      <body>

       

      <h3>Inject Test</h3>

                <%

                          if ( null == pers ){

                                    %>

                                    <h3>Inject failed!</h3>

                                    <%

                          }

                          else{

                                    %>

                                    <h3>Inject OK</h3>

                                    <%

                          }

                %>

      </body>

      </html>

      {code}

      Attached the whole source code of the application, tried with AS 7.1.0.

      In AS6 that works (I get "Inject OK"), in AS7 it doesn't. Inject from a servlet works in both servers.

      My question is wether DI from a JSP should work by JEE-Standard or not? Did it work in AS6 only by accident or is it a missing feature in AS7? Or did I just miss a configuration?

       

      Thanks for any information on this. Relevant links to to JEE-standards definitions would also help.