• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Is this MVC?

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a sample web application using the Model view controller pattern. I have a handlerServlet which I use to pass control to other servlets. Those servlets contain some of my business logic and in turn pass control to JSPs for display. Like depicted below

handlerServLet --> Task specific servlets --> JSPs (results / user inputs)

Now, based on certain user inputs I need to forward the user from the JSPs to some other servlets. I reckon this is going to get me into a bit of a mess.

Is it alright that I pass the control back to the handlerServlet and then go to the respective servlet from there? On the other hand, isn't it a bit of an extra overhead when the control can go direct from the JSP to another servlet?

This is the dilemma I am facing. Can someone advise?

Also should I make a servlet for each business logic task that I want to perform? Or should I just have a new method in my handlerServlet?

Thanks.
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
standard practise is ur 'handler servlet' takes care of moving to the next jsp after invoking other process related servlets.
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think about Separation of Concerns. "Each object should be responsible for one and only one thing."

From what you say, the handlerServlet is just responsible for page flow (much like the ActionServlet class in Struts). The other servlets are responsible for business logic and hence, should not be concerned about the page flow.

BTW, have you considered using Struts. It does exactly what your handlerServlet does and much more.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to use servlets to handle the business logic. You only need to use servlets/JSPs when you need to perform something that requires interaction with the HTTP protocol. Thus, your handlerServlet should only process the request as it's coming in and going out (redirect to the appropriate JSP).

Use a plain java object to perform the business logic.

As far as Struts goes, I wouldn't use it until you are already comfortable with MVC/model 2.
[ September 23, 2004: Message edited by: Roger Graff ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic