• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC Pattern

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i have the below jsp which i want to divide into MVC(as adviced by Bear previously as the best practice. and thank you for that bear), i am unable to understand what goes unde Model, View and Controller.

please help me with it.

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you didnt employee servlet or servlet filter or some kind of controller . and here jsp is doing all the work .

in MVC, you need to define one role to one worker. normally
*JSP-best suite for view(should only contain logic for view).
*Servlet[known as controller]-he is good at delegating request to appropriate location/business logic.
*Java class-Obviously better to put your logic here.

So that, specialized people can concentrate their job with out interfering others.
and for example: jsp is best place to put html , view logic etc..
if you put their java class then it wont be convenient to maintain
[working in java code in java class is better than working in java code in jsp is in IDE]
and there are many reason why MVC is famous...
=> WhyNotUseScriptlets

and now you move all your business logic(java code) to java class and call the class from your servlet, hence submit your form/jsp to servlet
 
Rakesh Keerthi
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you seetharaman. i'll do it.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rakesh,

Venkatasamy is correct but if you want you can put one more layer between your servlet and Logic layer that will be good
In this layer you just provide the manipulations you want to do with your data and logic layer will only give you the
output of the query.In this way your last layer will be unplugged any time if you want to change your databas query or
type etc. In that you just have to remove the last layer in this .If you put any manupulations with data then it will be
very dependent on that layer.
Is it clear for you or just i confuse you more..Please reply.

Thanks.
 
Rakesh Keerthi
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vijay,

Thank you for the reply, It is a bit confusing, but, according to my understanding you say to seperate even DB logic from servlet and use it so that DB manuplation can be even more easy. please correct me if i'm wrong. if i'm right i'll proceed as you say.

Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read this article?

A JSP is part of the view, so it cannot be part of the model or controller.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic