jQuery in Action, 3rd edition
The moose likes EJB and other Java EE Technologies and the fly likes Someone please explain best practice for MVC.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Someone please explain best practice for MVC.." Watch "Someone please explain best practice for MVC.." New topic

Someone please explain best practice for MVC..

steve dowdall
Ranch Hand

Joined: May 23, 2001
Posts: 36
Can someone please give me a simple answer to this.
I have an EJB deployed on weblogic. Works great. I have a stand alone java client accessing the ejb. That works great too.
What I want to do know is run a client from a browser that uses the EJB. I have seen so many different ways of explaining it, it makes me dizzy.
I will need to collect two variables from the user. Should I put put the ejb create() code on the JSP? Should I use a servlet, if so for what? Should I simply use an html form and then call a servlet?
If someone can simplify this as to what the best practice is for performace and scalablity when doing something like this I would appreciate it. I'm sure I'm not the only one.
Alan Williamson

Joined: Nov 01, 2001
Posts: 14
A good application of MVC in J2EE is "Struts". Check out http://jakarta.apache.org/struts/index.html.
Manjunath Reddy
Ranch Hand

Joined: Jul 26, 2001
Posts: 60
A lot depends on what the two variables collected..end up doing. Are they parameters for search ...i guess immaterial of what they are, one can use html to collect the parameters and and use a "statelessSessionBean" in jsp to call the right method to process them. Then SSB can then delegate the request to either the appropriate EJB or do the transaction by itself. Without the specifics...cant say much. But i guess this should get you started.
steve dowdall
Ranch Hand

Joined: May 23, 2001
Posts: 36
the two parameters (employeeid and doctype) are being used by the ejb to do some table look ups and inserts for a document generation system. I have decided to go with a jsp page that collects the form data from the user and sends it via the query string to a servlet. The servlet will be the controller and do the look up and create() on the ejb. Based on a return value from the ejb, the servlet will generate a pass or fail html page bacj to the user. Round trip completed.
Any input appreciated....

Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Your suggestion sounds perfectly reasonable to me. That's pretty much the standard MVC practice. BTW, one thing you might consider is having your "failure" page be the same page that submitted the form for the search -- that way if you can trace the failure to one or more parameters on the form you can indicate which parameters aren't right.
I discuss this in this presentation:
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
[This message has been edited by Kyle Brown (edited November 01, 2001).]

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
steve dowdall
Ranch Hand

Joined: May 23, 2001
Posts: 36
Excellent. I'm grateful that people are willing to help each other
I agree. Here's the link: http://aspose.com/file-tools
subject: Someone please explain best practice for MVC..
It's not a secret anymore!