lundi 25 janvier 2016

Suitable J2EE Design Pattern

I have been mostly working on core java and not need to work on the J2EE part of the same in creating a web application.

I have a query with respect to design of the code.

If I am using J2EE as it is, without using any MVC framework, then all my request comes to my server in my servlet from my JSP.

Now in the Servlet, I want to perform a fixed number of operations

Eg: verifying the order, checking customer details, etc.

If these fixed operations are fine, then execute the another service.

In this case, should I use a single servlet and from there call different services OPerations based on if-else logic internally or Should I use different servlets and pass them the request&response object based on wheather the operation is success or failed.

(I want to follow the right design and keep my code clean and loosely coupled)

So in breif, it is like Servlet calling Operation A,B. If A=true, B= true, call Operation C

Servlet calling Operation A,B. If A=true, B= false, call Operation D

Servlet calling Operation A,B. If A=false, B= true, call Operation E

Based on different outcomes, I will render different pages. So in this case, will it be a good Idea to invoke a separate servlet for each operation ??

Kindly advice me with a score to my solution and further improvements to it

Please let me know in case my question is not appearing clear or need any more information.

Thanks

Cheers.:)

Aucun commentaire:

Enregistrer un commentaire