MVC Help

Hi

I am new to designing, I am not able to confirm whether my design explained below is a valid or proper one, should I improve in any other place.

M - Stateless session bean having methods for insert, update, delete, view,

V - Jsps, html, js, images

C - A single servlet for a single JSP

Sample

addUserGroup.jsp on submit it redirects to UGACtrler populates javabean UsrGrp and instantiates UserGroupBean ejb and calls the corresponding method for inserting or updating.

updateUserGroup.jsp on submit it redirects to UGUCtrler populates javabean UsrGrp and instantiates UserGroupBean ejb and calls the corresponding method for inserting or updating.

and it goes for all database operations.

Please suggest me whether this is a proper way of doing it.

regards

[830 byte] By [gopalkisa] at [2007-9-29 11:38:15]
# 1
> I am new to designing> ...> Please suggest me whether this is a proper way of of doing it.Yes this is well on the right track.
MartinS.a at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
Thanks for the help, Now I can confidentally do the rest of the modules. regards
gopalkisa at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
I would suggest that , It is better if you can create EJBs and Servlets for a specific set of functonalities.Rather than each and every function. Ex: UserManagerEJB is for all the user specific functions etc...
jayalalka at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
hi, C - A single servlet for a single JSP are you using a servlet for all the JSPs or using different servlets for each jsp request ?
srinathreddy_ka at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

Hi

In My design I used one jsp for one functionality and one servlet for each jsp as controller for that functionality and an EJB for all the functionalities. I saw more servlets coming into picture but I felt it will be easy to maintain and code also. I feel like if one servlet is used for all the functionalities, maintaining the code I felt it will be difficult.

addUser.jsp -> addUserServlet controller -> User EJB (create method)

viewUser.jsp -> ViewUserServlet controller -> User EJB (view method)

... etc

Any comments on this design is welcome. I will also learn something if this design in purely wrong.

regards

gopalkisa at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 6

Hi,

I think you should avoid creating servlets for each jsp.

As a controller you need one one servlet.

My understanding from your design is you are having all business logic in EJB's. In that case what is the need of many servlets.

Following modification would sound better ...

JSP1 --\/--bean1 //this can be EJB

JSP2 ControllerServlet -- bean2 //or just bean, which comunicats with EJB

.........

You can refer to working of few frameworks like struts, SunONE application framework for more info on MVC design

pmas123a at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 7
Hi Thanks, I have gone through structs framework, now I am confident about MVC how it can done, I am through with the design. Thanks for all.regards
gopalkisa at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...
# 8

I would go with one Controller Servlet for all the JSP's, Since all the Business logics are in the EJB. And your Controller should navigate between the JSP's. But each JSP can have Individual Java Bean to store Request values from the client browser. I would suggest you to go thru the Struts Framework for better understanding.

With regards

Karthic

b.m.karthica at 2007-7-15 1:09:12 > top of Java-index,Other Topics,Patterns & OO Design...