• 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

JSP database application setup

 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a JSP application that queries a database and moves thru result set. Right now I have a class that builds all the input boxes of database fields (so they can me modified), the same class handles database query and sets value parameter of input box with returned data. With this setup one class does everything: builds the screen and populates it each time database is queried. So if a user hits search, screen is build. Hits next, screen is build again from scratch. Should I keep this setup or create another class that just handles database stuff and updates the fields using JavaScript (document.form.field1.value=<%=data%> ? Is this method better? Or should stay from merging JavaScript and JSP on database queries?
thanks a lot for your input,
Alex
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't use Javascript at all for something like this. Nor would have all these levels of functionality in a single class.
For even my most simple web applications, I always follow an MVC-patterned layering in which the "model" exports the data in a completely UI-agnostic manner. I then use servlets to control the actions of the web app, and JSPs with template text to render the web UI.
Some might argue that for small apps that this is "too much work", but I have always found that the investment pays for itself time and time again (and once you get used to doing it this way, it frankly isn't a whole lot of extra work -- it's more in the organization than in the amount of code).
[ April 07, 2004: Message edited by: Bear Bibeault ]
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks.
Do you have any documentation I can look at to learn more?
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I totally agree with the idea that following the MVC is a time saver when you look at your web application during a longer period.
And one of the books that helped me working my way through the MVC, servlets, beans and JSP's is "core servlets and JavaServer Pages" from Marty Hall. Mary Hall also has a website where you can take a look and even download the pdf-file of the first version of his book : http://www.coreservlets.com.
Another very good book, contaning a full web application built in MVC style, is "Apache Tomcat Bible" (Jon Eaves, Rupert Jones and Warner Godfrey). This book even explains how to install Tomcat, Mysql and other stuff to help you build a Java Web Application.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Gert,
In online version of Marty's book, which part discusses MVC?
thanks,
Alex
 
Gert Cuppens
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid I have to disappoint you, Alex.
Marty Hall does not speak about the Model-View-Controller in his book.
The reason why I think Hall's book is very good, is that he describes in detail the working of servlets and JSP's. And I still get a lot of tricks out of his book.
But if you want to know more about the MVC, then there is the "Apache Tomcat Bible" from Eaves, Jones & Godfrey (Wiley Publishing, Inc).
This book has the advantage that it not only explains the theory behind the MVC. But you can as well build a whole web application, based on the MVC. The source code of this web application can be downloaded at http://www.wiley.com/legacy/compbooks/eaves/.
Where Marty Hall is very good at explaining the details and tricks of servlets and JSP's, this book is an essential one for every one who wants to build web applications with Java, Tomcat and MySQL.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic