Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes another mvc question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "another mvc question" Watch "another mvc question" New topic
Author

another mvc question

Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
hi,

two questions actually...

1. while reading some stuff in the j2ee blueprints i've found that the authors use a "mappings.xml" file to forward the request from the front controller servlet after it's done with the business logics execution... i don't think i've ever seen any usage of this file before. have you?

2. thinking about model and controller separation... this is actually a question for those of you beliving their desing is "clean" and all of the logics layers are clearly separated. in the majority of cases the redirection from the controller on after the business logics execution depends of the results we get from the business logics methods. to code those business methods to return strings which are actually the uris the request must be forwarded to means to mix a model with a view. so, we can return int or string which will be used as "codes" by controller for future redirection of the request. my question is how do you do it. what is your way of doing this.
thanks.


Asher Tarnopolski
SCJP,SCWCD
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
2. while using Command pattern along MVC architecture, my servlet check the command and pass the request and resultant JSP page to the model. if there is some error while processing business logic. model changes that page to an error page and return it to the servlet or return a boolean "false" to the servlet, then servlet will forward that error page to the client or throws an exception which is caught by exception tag in web.xml.

how it sounds??
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
you see, if you make your model return the path to a page, you mix it with the view. just think about it: if you wanna change the page you want your controller to send response to, you have to make changes in the model...
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
no no. i have said both the things. read it carefully or may be i haven't explained clearly.

- my controller knows where to forward the client. model just changes the page when error or exception occurs.

the other option is better, and completely seperate.

- my model just throw error or exception if occurs. otherwise my controller knows where to redirect the client. if model return false then client will be directed to the error page defined in web.xml.

you have to receive something from the model, not the uri but at least exception to indicate whether operation is successful or not. isn't it??
[ October 02, 2004: Message edited by: adeel ansari ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by adeel ansari:
- my controller knows where to forward the client. model just changes the page when error or exception occurs.


you can also say here that model and controller are seperate.

if you change the controller to forward the client to some other page. then you can do it just changing the url inside controller. model doesn't care about, whatever the page is.

but model knows i have to change the page, no matter what page, to error page if error or exception occurs.
[ October 02, 2004: Message edited by: adeel ansari ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: another mvc question
 
Similar Threads
More on MVC
Please help me to resolve this Design Pattern question
GUIContoller
How get method source code from a class
component diagrams.