I'm wondering if doing this is possible or if it's a bad idea. The Stateless Session Bean would need to get parameters from the Request Object and then setAttributes on it.
?
Discussions
EJB programming & troubleshooting: Can The ServletRequest object be passed to SLSB method?
-
Can The ServletRequest object be passed to SLSB method? (5 messages)
- Posted by: sfrgfsg sgds
- Posted on: January 08 2003 15:29 EST
Threaded Messages (5)
- Can The ServletRequest object be passed to SLSB method? by Tomas Inger on January 09 2003 02:35 EST
- Can The ServletRequest object be passed to SLSB method? by Flying Squad on January 09 2003 04:42 EST
-
Can The ServletRequest object be passed to SLSB method? by sfrgfsg sgds on January 09 2003 09:51 EST
- Can The ServletRequest object be passed to SLSB method? by Michael Malkinzon on January 09 2003 03:08 EST
- Won't work anyway by J. B. Rainsberger on January 13 2003 11:01 EST
-
Can The ServletRequest object be passed to SLSB method? by sfrgfsg sgds on January 09 2003 09:51 EST
- Can The ServletRequest object be passed to SLSB method? by Flying Squad on January 09 2003 04:42 EST
-
Can The ServletRequest object be passed to SLSB method?[ Go to top ]
- Posted by: Tomas Inger
- Posted on: January 09 2003 02:35 EST
- in response to sfrgfsg sgds
Hi!
ServletRequest does not implement Serializable, so from what I can see it is not a lega parameter to a (non-local) EJB method.
My recommendation is to create a value object class passing parameters from the Servlet to the SLSB.
/Tomas -
Can The ServletRequest object be passed to SLSB method?[ Go to top ]
- Posted by: Flying Squad
- Posted on: January 09 2003 04:42 EST
- in response to Tomas Inger
Is this also a violation of the standard MVC architecture? Should we not use DTOs etc. to transfer data into a EJB? -
Can The ServletRequest object be passed to SLSB method?[ Go to top ]
- Posted by: sfrgfsg sgds
- Posted on: January 09 2003 09:51 EST
- in response to Flying Squad
I am aware of these concepts but my problem is because
depending on certain form data submitted the method must set attributes of different types in response so i would have to make a different EJB method for each possible result. Thanks for thnbe advice anyhow. -
Can The ServletRequest object be passed to SLSB method?[ Go to top ]
- Posted by: Michael Malkinzon
- Posted on: January 09 2003 15:08 EST
- in response to sfrgfsg sgds
If you don't want to create various DTOs use HashMap as a generic DTO instead, some of this is outlined in the EJB Pattern book. It is not as cohesive, but in cases where you do not want keep changing the interfaces to you app it is effective.
Mike
MALKI SYSTEMS INC -
Won't work anyway[ Go to top ]
- Posted by: J. B. Rainsberger
- Posted on: January 13 2003 11:01 EST
- in response to sfrgfsg sgds
Even if you passed the HttpServletRequest into the EJB, you'd be passing by value and not by reference, so changing the request's state in the EJB does not guarantee that the state is called in the request object in your web container. If you're not passing the request by reference (local EJB), then it just won't work.
If you are passing the request by reference (local EJB), then I suggest using a generic collecting parameter and passing *that* into the EJB instead. Implement some narrow interface that includes an "attribute setter" of some kind, then wrap the request in an implementation of that interface and delegate. The goal here is to maximize the substitutability of another implementation for testing or refactoring.
If you need an example, let me know; otherwise, good luck.