If there is only a form for user to input data, how can I implement it
by MVC?
Currently, I achieve it by:
1) View: there is a jsp for user to input data.
2) Controller: there is a servlet which is called by the form acton. It
is responsible for two tasks:
a) insert data to database ( the data is retrieved by
request.getParameter(). Is it better to achive it by using java beam?
b) if the insertion is successful, the servlet will forward to a
thankyou page, otherwise it will forward to a error page.
3) Model: ?? here, I don't know whether I shoud use java beam...
Manish Pandit - 24 Oct 2006 19:37 GMT
Model is something that has the 'system state', which in your case is
the database that gets changed.
request.getParameter() is fine but this will not work if the form is
multipart (contains files). Also, make sure the form submits via a Post
since it is changing the model. You can use a formbean (like a javabean
but tightly coupled with the form) if you are using a framework like
Struts.
-cheers,
Manish