• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best practice?

 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Been out of Web dev for about the last 5 years and lately have been doing all straight Java. Recently I switched projects and inherited a web app down is jsp and servlets that the customer wants customized to their needs. I have a general some design practice questions and looking for guidance before I jump straight in. Basically right now there is a jsp with a form and when the form is submitted certain parties are emailed. The email code and who to send it to right now is in the servlet. The customer wants this to be changed based on a "project" drop down list. For example if project "A" is selected then send an email to the person who submitted the form, a but if project "B" is selected from the drop down maybe send an email to the submitter and maybe the submitter's boss and if project "C" is selected blah blah blah. I am wondering where is the best place to put this kind of logic? Should it go in some JS in the jsp to set some hidden vars and then let the server side figure it out? Should I do all the logic on the server side based off the value in the selected drop down (the project name)? But what if the project name changes??? I want to remain generic flexible enough to be able to handle new project conditions and possible name changes. Any thoughts?

Thanks!

AMD
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep the specific info off the client. Just send a value back to the server where any business decisions should be made.

Me, I'd even have all this at a lower level than the servlet -- in a business layer that's completely UI agnostic.
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for the input. So when you say a business layer are you suggesting a set of classes that the servlet will delegate out to, to handle business logic based off the input entered?

Thanks,

AMD
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely. It's best to have the servlet layer delegate business logic to a separate business layer, independent of the UI.
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome thanks for the info Bear
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's best to have the servlet layer delegate business logic to a separate business layer, independent of the UI.


Bear, please elaborate
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kunal Lakhani wrote:Bear, please elaborate

Look up Separation of Concerns.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!