jsp sample code, mysql, first website

Posted on 2003-03-25
Medium Priority
Last Modified: 2010-04-01
i need to create a website for a non-profit org and have a full db schema planned etc.  but i have seen many snippets of code all over the web, some that make DB calls within the jsp pages, other that use the mvc design paradigm and use struts, etc.  is there a place that i can get a starter code package that i can modify for my non-profit?

i just need to retrieve content from the DB and display it on the web using
Tomcat4.1, MySQL, and JDK1.4.  

I have learned that the best way to code is probably with a special Bean that is responsible for talking to the DB (Model) but I have failed to find ample sample code on the web of how to create a bean and call it from the JSP.

Any help would be appreciated.
Question by:mgupta1013
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 19

Expert Comment

ID: 8205585
first make sure you have the mysql jdbc driver added to your classpath (for compilation) and tomcat/common/lib directory

you can get the jdbc driver from here:

here is a good example of a DB bean:


Author Comment

ID: 8206379
that is a good example, but i thought that the JSP pages were not supposed to know anything about the underlying DB schema, correct?  It appears from that example that the JSP page actually defines the SQL and then just uses the bean to execute the SQL.

I thought that is not the correct way to program MVC 2, no?
LVL 19

Accepted Solution

cheekycj earned 225 total points
ID: 8206413
you can create helper methods that retrieve specific data and run the SQL for you inside that bean or another bean.  But the example above is a good start to atleast create a basic db access bean and you can use that to create other helper methods or other beans that completely hide the data access process - following DAO pattern.


Author Comment

ID: 8206459

Do you know how struts play into the picture.  I have downloaded struts pkg, and gone through a lot of docs, but I have failed to understand how people use them in the web deployment world.

Additionally, do you know a location/packaged suite of ready to use beans?

LVL 19

Expert Comment

ID: 8211566
just search on google for jsp beans .. I am sure there are plenty.

a good resource is www.jspin.com

as far as struts goes, its pretty much providing a tag based approach to do MVC:
good guide/tutorial sites:
http://developer.bluestone.com/scripts/SaISAPI.dll/Gallery.class/demos/trailMaps/index.jsp?sect=3&area=trail [tutorial]


Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Summer 2017 Scholarship Winners have been announced!
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question