Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jagdish Hatagale
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New records don't have a unique ID. Existing records do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic