• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how does first jsp page access database?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I want my first page, index.jsp, to access database and show some results, how can I do it?
As I read in one tutorial, the first url can be "/index.do", then I can get the results to be shown in the index.jsp. But is there a better solution?
maybe I should use custom tags. is it right?
thanks
[ January 02, 2003: Message edited by: xallan ]
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xallan,
We don't have many rules at Javaranch, but our display name policy is one of them. Please read this policy and change your display name to comply with it if you wish to continue posting. Thanks.
You can change your display name here.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While you can technically do anything you want in a JSP, it is considered bad form to have the view (in this case your jsp) making direct access to the database. The typical way you would handle this in Struts is to have your action place some kind of value object into some scope which your jsp would then access.
In other words... Your Action populates a bean (the value object) based on data contained in some business object, and places that bean into some scope. It is this business object that actually communicates with the database. The JSP then references your bean and displays its data appropriately.
If you insist on your jsp directly communicating with your database, perhaps the JSP forum would be more appropriate.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic