[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - Example in JSP expression language and JSP scriptlets, diffe

alen_ribic do-not-reply at jboss.com
Tue May 19 06:12:16 EDT 2009


I have a Servlet that sets an Action Bean instance as an attribute called 'actionBean'.
I also have successfully setup an AOP interceptor (with load time weaving) to intercept the User bean's getName() method.


  | class User {
  |    private String name;
  | 
  |    // getters/setters
  | }
  | class ActionBean {
  |    private User user;
  |    
  |    // getters/setters + other action methods
  | }
  | 
  | class MyServlet extends HttpServlet {
  |    public service(HttpServletRequest req, HttpServletRequest resp) {
  |       User user = new User();
  |       user.setName("Bob");
  |       ActionBean actionBean = new ActionBean();
  |       actionBean.setUser(user);
  |       request.setAttribute("actionBean", actionBean);
  |       ...
  |    }
  | }
  | 

In the JSP context I try the following JSP scriptlet:

  | <%
  |    ActionBean actionBean = (ActionBean)request.getAttribute("actionBean");
  |    User user = actionBean.getUser();
  |    out.print("user: " + user.getName());
  | %>
  | 
And the call works 100% with the AOP interceptor being called.

However, I try the same with JSP expression language:

  | ${actionBean.user.name}
  | 
And the calls works BUT the AOP interceptor does not get called.

Somehow it seems that the JSP expression language and JSP scriptlets get evaluated differently and as a consequence my AOP interceptor does not get called.

Any help would be greatly appreciated.

-Alen

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4231833#4231833

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4231833



More information about the jboss-user mailing list