MVC Design Help, Single Servlet, How do I access the Model and DB
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jazz_Badwal
Posted On:   Tuesday, October 12, 2004 01:51 PM

Hi all. New here and looking for some help. I am currently writing a website that allows the creation of users, that may upload articles and post comments on articles. Im trying to develop using MVC. I have a single controller servlet that processes POST actions throughout the site (eg. InsertArticle, DeleteArticle, ModifyArticle, etc..) Now my problem is, just how do I retrieve the articles from the database? .. for example, if I load up a page http://localhost/articles.jsp which should display all the articles currently in the site.. I would have a function say getAllArticles() which should return a collection of all the articles. I can then iterate through the articles in the jsp page. I am try   More>>

Hi all. New here and looking for some help.



I am currently writing a website that allows the creation of users, that may upload articles and post comments on articles. Im trying to develop using MVC. I have a single controller servlet that processes POST actions throughout the site (eg. InsertArticle, DeleteArticle, ModifyArticle, etc..)



Now my problem is, just how do I retrieve the articles from the database? .. for example, if I load up a page http://localhost/articles.jsp which should display all the articles currently in the site.. I would have a function say getAllArticles() which should return a collection of all the articles. I can then iterate through the articles in the jsp page.



I am trying to use BUT.. my articles bean constructor takes a databaseconnection object as a parameter. If I use useBean I cant pass the databaseconnection object to the bean and I get an error because it cannot create the bean.



Any help on this would be appreciated as well as any tutorial links. I also looked at the petstore blueprint program on the sun website, but that program has me completely lost with all the xml. I would prefer not to use custom tags or struts for now. I would like to keep it simple with snippets of java code in the jsp pages for data retrieval and display while keeping all the business logic in the beans of the model. I would also like to keep this relatively secure. I am developing using Oracle Jdeveloper 10g.



Thanks



Jazz

   <<Less

Re: MVC Design Help, Single Servlet, How do I access the Model and DB

Posted By:   Venkat_Hariharan  
Posted On:   Thursday, October 21, 2004 12:22 AM

Why don't you embed the call to the class in scriplets (ie <% .. %>) instead of tag. The outcome being having few lines of servercode embedded in your jsp..:-((.

Else you can also use the tag.
About | Sitemap | Contact