Forums Register Login

MVS Problem?

+Pie Number of slices to send: Send
Hi all,

I am learning JSP and Servlets. I am trying to do a small project in the area I have learned so far. Simply I am trying to do a MVC thing.

I am just adding/deleting/updating the customer registration details to the Database.
Now the section I havint the doubt.
I am using JSP for view that is, I am creating the form in the Customer.jsp (for example: Customer ID(int), Customer Name(char), Customer Age(int), Customer DOB(date))

I am using JavaBean for setting and getting the properties in Customer.java. (for example:
private String customer_id,customer_name,customer_age and customer_dob;
And getter and setter method.


Now whether the database connection and all other updating thing to the database should be kept at Servlets (i.e., Customer_Ser.java) or at JavaBean(i.e., Customer.java)

I have seen the database connection in JSP, Servlet and Javabean. I know it is very bad thing to do any database thing in JSP. But, which one is best to use the database connection ? in Servlet or Java (Javabean).

Is there any situation to use the database connection in JSP.

If possible, any sample coding(I have written the coding, but I want to know, which one is having better performance and also see how the real appln have coded in the MVC) for just adding the details to the database in MVC Pattern.

Thanks in advance,
+Pie Number of slices to send: Send
If you are following the MVC pattern, the DB connaction should definitely not be in the JSP or servlet. Usually, that will be part of the model/business logic. Enterprise level applications would even separate it further by putting it in it�s own class using the DAO pattern.
+Pie Number of slices to send: Send
No servlet, no javabean, for database connection use separate class(classes). Maybe take a look at some DB related patterns as DAO for example.
+Pie Number of slices to send: Send
thanks for your reply.

So I can say that JSP only for view that is for presentation like GUI(forms).
Servlets for controller.
And what about JavaBeans? it is only for Property only?
can i get any sample codings or example in website for Model-View-Controller
Even JavaBean also a Java file with some speical properties. Why you are telling not to use database connection in JavaBean.

If I am using separated class for database connection, what will be the use. In that case for example, for registration of the customer details in the database requires the following files. (pls, at this moment EJB is far away from my learning)

Customer.jsp - For Forms
Customer_JavaBean.java- For getting and setting properties
Customer_Servlet.java - For controlling?(Having doubt in this file of his
role
Customer_DB.java - For database connection

How these four will interact. I want the example thing for the above mentioned thing. If possible, pls provide the link. I had searched in google, but I am getting some complex mvc with EJB.

Also suggest, the above four files are mandatory for fulfilling a Good MVC Pattern.
+Pie Number of slices to send: Send
Can I get the sample or example codings in the DAO Pattern. I have searched in google. Not getting any useful/related to my problem. Just I want to add the customer/student details in the database by using MVS, or as the group member told as DAO. How to use it, any sample or example coding will be available.
+Pie Number of slices to send: Send
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 793 times.
Similar Threads
I want to develop my own jsp site
Advise if I am in correct direction
Opening Pop up WIndow from action class
Query on JPA Annotation
Invalid oracle URL
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:39:41.