aspose file tools*
The moose likes Servlets and the fly likes Can I use single servlet and a single model to satisfy two functionalities. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can I use single servlet and a single model to satisfy two functionalities." Watch "Can I use single servlet and a single model to satisfy two functionalities." New topic
Author

Can I use single servlet and a single model to satisfy two functionalities.

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi everybody, I am Chaitanya, I have a doubt regarding MVC architecture.

Suppose take an example where there is a user registration page, The user registers to a particular site providing all his details. This time we use a model which enters the details into the database. Next the user wants to update all his details. This time also all the details will be entered into the database, but it is a update. Not new record.

In both cases the servlets receive same parameters. The difference is in the model. Can I have one single servlet which takes the user details and depending on the request it calls update method or insert method in the model.

Here the servlet which inserts the user details is a multi part request. The servlet which updates the details is a simple request.

Is this right approach? Can anybody tell me?

Thank you all in advance. Have a great day.


Love all, trust a few, do wrong to none.
Jagdish Hatagale
Ranch Hand

Joined: Apr 07, 2010
Posts: 33
yes this is posible you can perform as many reaquired opration in servlet on the basis of comparing conditions,
sipmply write the servler with service method and over ride the methoda which ever you want from that service method for diffrent functioanlity which perporm the task on the basis of request.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

New records don't have a unique ID. Existing records do.
 
Consider Paul's rocket mass heater.
 
subject: Can I use single servlet and a single model to satisfy two functionalities.