• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

Ranch Hand
Posts: 806
MySQL Database Spring Java
  • 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.
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.
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.
    Bookmark Topic Watch Topic
  • New Topic