• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Someone please explain best practice for MVC..

 
steve dowdall
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Cheers,
Steve
 
Alan Williamson
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good application of MVC in J2EE is "Struts". Check out http://jakarta.apache.org/struts/index.html.
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Cheers!
 
steve dowdall
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,
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....

Steve
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
http://hometown.aol.com/kgb1001001/presentations/OOPSLA01Tutorial.pdf
------------------
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).]
 
steve dowdall
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent. I'm grateful that people are willing to help each other
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic