[MVC] If there is only a form ...

L

littlebeam

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...
 
M

Manish Pandit

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top