Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP MYSQL

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I was on here yesterday trying to get some help but am still stuck exactly where I was yesterday. I am making a website for football clubs and i have a database witht the following fields:

ClubID
ClubName
ClubManger

On the first page,clubs.jsp, I want there to be a list of clubs names from the database. When their clicked on I want the database to be accessed and the the clubid to be retreived. I then want to be brought to the next page, profile.jsp and display the Club name and manager according to that ClubID. Please Please Please can some one help me with this code Please. I am a complete beginner at JSP so please be gentle.

Thanks,
Colm
 
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the best thing to do would be to hit your favorite computer bookstore or the public library. Database-connected webapps are not something that can be well covered in a few short paragraphs. Industrial-grade webapps can be very complex.

The one thing I will say is that it's not considered good practice to access databases - or do any other sort of logic processing - directly on a JSP. While it's commonly done on ASPs and in other quick-and-dirty systems like PHP, the intermingling of the data (Model), the page display (View), and presentation interface logic (Controller) does not scale well if you want to produce something that's reliable and easy to maintain.

And since Java and its frameworks tend to require a lot of up-front work, it's usually used for the heavy-duty stuff. Easier to do PHP or something like for lightweight one-off projects, just like Visual Basic vs. C++.

However, if you want to do so: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jsps/jstlsql.html

Even if you're not using Oracle, this should be a good start - the main difference is that other databases require different connection info.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Tim Holloway:
Actually, the best thing to do would be to hit your favorite computer bookstore or the public library. Database-connected webapps are not something that can be well covered in a few short paragraphs. Industrial-grade webapps can be very complex.

The one thing I will say is that it's not considered good practice to access databases - or do any other sort of logic processing - directly on a JSP. While it's commonly done on ASPs and in other quick-and-dirty systems like PHP, the intermingling of the data (Model), the page display (View), and presentation interface logic (Controller) does not scale well if you want to produce something that's reliable and easy to maintain.

And since Java and its frameworks tend to require a lot of up-front work, it's usually used for the heavy-duty stuff. Easier to do PHP or something like for lightweight one-off projects, just like Visual Basic vs. C++.

However, if you want to do so: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jsps/jstlsql.html

Even if you're not using Oracle, this should be a good start - the main difference is that other databases require different connection info.



I have the same type of project as mentioned by the OP and I am using Java with MVC. I would think MVC is the best way to go on all web projects small or big? Since I started using MVC I think it is the best way to go even on my small projects. I think PHP has several versions of MVC, with one of them called Cake. Also what kind of up front work are you talking about in this statement: And since Java and its frameworks tend to require a lot of up-front work.

Thanks
[ April 12, 2008: Message edited by: Ed Carrington ]
 
    Bookmark Topic Watch Topic
  • New Topic