Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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

Proper mix of Servlets and JSP

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a "proper" way to mix Servlet and JSP pages together? The book I have "More Servlets and JavaServer Pages" says that JSP pages should mostly be concerned with formatting of data received by a servlet.
So does this mean that the Servlet should take care of Data collecting (be it either a Database or some other source) and the JSP page should just take that data and display it.
In my current project I am downloading email message information from an email server and storing the messages in a Vector. Then the JSP page just uses the data from the Vector instead of making its own connections.
In the future I would also use the method for database information. One problem I see could be if the data you are collecting is really large, say from a large database table.
Thanks for any info,
Kenny
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a good way to use JSP, and helps encourage a separation between the data model and the presentation.
As for your worry about loading large database result sets. You are right to worry, but the solution is not some kludge to connect to the database direct from the JSP, but instead to spend a little time thinking about why you have large amounts of results, and how to reduce them.
Web application users need precise, targetted information, and rarely have any use for mile-long screens full of stuff (imagine if this bulletin board were just one huge list of thousands and thousands of posts ). A query which returns so many results is usually due to a mistake or an inflexible query system. Study the users' needs more, find out how they would refine the query, and offer them that option.
 
author
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good response.
David
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic