• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

jsp database connection

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all...

why don't we prefer to create a connection to database in jsp .
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hindustani

You can no doubt do it. Its doeable also. Infact this is what use to happen in Model 1.

But the question is to provide the best/optimized/scalable....... solution for a problem.

MVC Model 2 gives one such solution, where in
Jsp -> Servlet -> Facade -> DAO -> Database

why don't we prefer to create a connection to database in jsp .



In case you have more doubts, feel free to ask
 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so what is your answer?
am i reducing the performance of application
or am i increasing the complexity of the application by following the mvc1 architecture

am i going for illegal architecture
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSPs are meant for display logic. You shouldn't put any business logic / database code in it. Seperating Model, View and Controller makes your application more maintainable.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not true that we cannot connect Db from jsp,But it is not a preferable approach:

jsp--->Db like tier 1 model
jsp--->servlets---->dataobjects--->Database MVC Model

Model:Data Objects
View: always The presentation layer have light component(this is the reason we make a Db connection at the Backend may be in DAO or Servlets)
Controller:Here Controller is a Servlets Actions
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me make it clear.

Model 1 is not MVC
Model 2 is also known as MVC

Think about few of these factors you will get your answer.
- code complexity
- maintenance nightmares (includes adding new features, fixing or modifying previous code)
- reusability
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic