understanding
hey whats up, okay so i have a few basic questions
okay, i set up a small app with java/jsp and i use beans. it all works fine. blahblah. anyway, traditionally what type of programing should go in the bean, and what in the servlet?
let me give an example, lets say im making a web forum, would i just use the bean to store variables for the jsp to grab? if so would i do any type of database query in the bean?
i read a little about MVC, or model 2, or what ever the hell its called, but it really didnt go into too much detail.
i had another question lemme think... oh yeah, what type of database is used most in java? i know php traditonally uses mysql, does java have one? thanks a lot
> okay, i set up a small app with java/jsp and i use
> beans. it all works fine. blahblah. anyway,
> traditionally what type of programing should go in
> the bean, and what in the servlet?
This is not a basic question
> let me give an example, lets say im making a web
> forum, would i just use the bean to store variables
> for the jsp to grab? if so would i do any type of
> database query in the bean?
This is not a basic question, but to give you a short answer - the point of beans to to avoid db queries
> i read a little about MVC, or model 2, or what ever
> the hell its called, but it really didnt go into too
> much detail.
I'm not sure this is a question at all.
> i had another question lemme think... oh yeah, what
> type of database is used most in java? i know php
> traditonally uses mysql, does java have one? thanks a
> lot
I don't think anyone could tell you this for sure. Java can connect to almost any database pretty easily
> hey whats up, okay so i have a few basic questions
>
> okay, i set up a small app with java/jsp and i use
> beans. it all works fine. blahblah. anyway,
> traditionally what type of programing should go in
> the bean, and what in the servlet?
>
In a relatively simple MVC-2 implementation, your JSP is your view, your Servlet is your controller and your bean is your model.
> let me give an example, lets say im making a web
> forum, would i just use the bean to store variables
> for the jsp to grab? if so would i do any type of
> database query in the bean?
>
You would create a data access object (DAO) that will query the database. Its job is to either populate a bean with data on a SELECT or take data from a bean and perform an INSERT, UPDATE or DELETE. The JSP would "know" nothing about the DAO, only the bean.
> i read a little about MVC, or model 2, or what ever
> the hell its called, but it really didnt go into too
> much detail.
>
The model is what makes your system unique. It depends on nothing. The view is the user interface (your JSP). The controller responds to user requests (web posts, link clicks, etc.), and in a simple application this will be a Servlet. The controller and the view are closely coupled. The controller is 'built' to service a particular view. The view is also 'built' to send certain events to the controller. The two together are your UI (or delegate as they are sometimes called). The UI depends on the model. However, the model should be agnostic to any particular UI or client. That's MVC.
> i had another question lemme think... oh yeah, what
> type of database is used most in java? i know php
> traditonally uses mysql, does java have one? thanks a
> lot
mySQL and Postgres are both outstanding free databases to use. I prefer Postgres myself, but mySQL seems to have more adherents, generally. You can always go commercial ala Oracle or DB2. And finally, for your own development, HSQLDB is in memory (or on filesystem) and free.
- Saish
BTW, take a perusal of the "Patterns and OO Development" forum. It has dozens (if not hundreds) of threads on MVC.- Saish
stevo,
A forum is all about client interaction... so I suppose it would make extensive use of JSP's
I'm no expert, But let's see... the forum is censored... I'd want to do that in java... so maybe the post (submit) button on reply.jspa would call post.jspa which might use a Censorship bean to do the ummmm censorship.
... such a bean might be useful to Sun in other applications ...
keith.
Message was edited by: corlettk