Database Backend?

M

mrhaydel

I currently maintain a webiste at work that consists of mostly .jsps, a
few servlets, nothing super complicated. There's a front page on the
website that contains version info (version number, date of release),
and a short little news section with blurbs about new things going on
with the software available on this site. Also there are some release
notes pages that are updated with each new release as well.

What I'd like to do is make this front page, and maybe the release
notes page, more data driven, so that instead of having to go in with
each release and change the HTML/JSP pages, it can just pull this info
from a few tables in a database. We use SQL Server, so I'd be creating
the database there, and like I said, I don't think it's anything real
complicated, it's just I've never done it before, and I'm having a hard
time putting what I want into words enough so that I can find articles
or whatever on doing this.

Can anyone give me a head start, maybe point me to some tutorials or
sites on doing this, recommend any books, etc, or really any sort of
help?
 
O

opalpa

Getting data our of the database is not that tricky. There is a second
part of how content creators put the data in. Inserting into a
database is not that tricky either but creating the interfaces for
content creators adds work. Possibly you could use something other
then a database first. Like having content creators drop content files
off to some directory and you pick them up.

You could later switch to a database driven approach. One thing that
facilitates switching is using DAO from struts as talked about on pages
like http://struts.apache.org/struts-doc-1.2.7/faqs/database.html

Basic idea: you specify the interface for the things you need retrive
(version number, news items) and the later can swap in a database
implementaiton for one that reads content files dropped of by content
makers.

(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
C

Chris Smith

What I'd like to do is make this front page, and maybe the release
notes page, more data driven, so that instead of having to go in with
each release and change the HTML/JSP pages, it can just pull this info
from a few tables in a database. We use SQL Server, so I'd be creating
the database there, and like I said, I don't think it's anything real
complicated, it's just I've never done it before, and I'm having a hard
time putting what I want into words enough so that I can find articles
or whatever on doing this.

Can anyone give me a head start, maybe point me to some tutorials or
sites on doing this, recommend any books, etc, or really any sort of
help?

Where are you starting from? Do you know SQL? JDBC? Hibernate or
another ORM product? (If you don't already know an ORM product like the
back of your hand, this isn't a big enough product to bother learning
one as is.)

If this is throw-away code, building it with JSTL and JSPs should be a
one-hour job. If not, then it depends on what you want in terms of
design and reusability.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

mrhaydel

I can't say I've ever used struts, and I suppose it's worth a look
into, but at the same time, I guess I envisioned there being a way to
do this without needing to go to a framework like struts.

What I had thought was that there'd be some "plain old" java code that
can be used to interface/read/manipulate the database tables that I can
more or less drop into the pages that I want to be tied in with the
database.

Your content idea is something we had used for a while, but instead of
me picking up what they had edited, we just broke off those few pages
that were updated on a regular basis so that anyone could edit them at
any time without having to do any other work. However, it wound up
usually being me that did it, so I don't think we'll be doing that any
more.

So, is what I'm asking or wanting not well handled by plain java, or is
struts the only way?
 
M

mrhaydel

I personally know SQL, but not quite like the back of my hand. JDBC,
Hibernate are new to me as well. One other thing is that this isn't
going to be just me doing this, I'll certainly have help from other
people here, and most likely they'll be able to get me going, but I'm
just wanting to see what I can't find out there first.

I guess you could sort of consider it throw-away code, but also this
will be something that needs to hold up and still do the job without
being real shaky. So JSTL is something to look into then and can be
implemented without a whole lot of trouble?
 
M

mrhaydel

And actually I see here with a real quick browse that the JSTL has tags
to interact with a database, so I'm guess that's what you were
referring to Chris. Now, I know JDBC may be fairly large and
potentially overwhelming, but is it feasible to pull out what I need
from it to do what I'm wanting, without getting too in over my head?
 
O

opalpa

Struts is not needed. I was thinking maybe it was already alongside
your JSP environment.

There are books about database coding with Java and there is sample
code on the internet.
http://www.javaworld.com/javaworld/jw-01-1998/jw-01-bookreview.html has
book reviews.

I think making the calls from your JSPs and getting content into your
web pages is going to be easy for you. A bit or two of configuration,
but once it is configured getting content will be easy.

I believe you'll spend more time making a system for content writers to
get their data in.

Here is one specific thing to keep in mind when you are writing Java
database code: if you are directly manipulating connections you need to
release the resource after using it. There are database connection
pool classes on the internet that will help you manage connections.
It's bad to run out of connections. Other than that it is regular Java
programming.

Good luck; Have fun
http://www.geocities.com/opalpaweb/
 
M

Malte Christensen

I currently maintain a webiste at work that consists of mostly .jsps, a
few servlets, nothing super complicated. There's a front page on the
website that contains version info (version number, date of release),

It sounds to me as if you only need to polish up on a bit of JDBC. Wrap
the JDBC in some beans and use those in your JSP's. Obviously, the data
needs to be maintained in the database, that is another story, but for
small stuff it is rather easy to throw together a JSP for data entry,
then stuff the data into the database instead of pulling it out.
 
C

Chris Smith

And actually I see here with a real quick browse that the JSTL has tags
to interact with a database, so I'm guess that's what you were
referring to Chris.

That's the quick and dirty solution. If you just need to write this
once, go for it. If it needs to survive change and evolution over time,
then it's worth the time now to do it right.
Now, I know JDBC may be fairly large and
potentially overwhelming,

Not really. It's rather simple and straight-forward, if you know SQL.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

Scott Ellsworth

What I'd like to do is make this front page, and maybe the release
notes page, more data driven, so that instead of having to go in with
each release and change the HTML/JSP pages, it can just pull this info
from a few tables in a database.


The answer depends on whether you will have to change this much in the
future, or whether you have a pretty good idea of what it needs to do.
Further, it depends on whether you _want_ to learn some new technologies.

If you do not see much need for change, and you do not want to work with
this in the future, then quick and dirty is probably ok. Learn SQL,
jdbc, JSP, and go to town.

That said, I have never had a project I could just ignore. Even the
'easy ones' seem to come back, so it is often worth using a reasonably
big hammer. Thus: a decent presentation layer, and a decent database
access layer become your friends.

I usually use some kind of object relational layer when I have to talk
to a database. Even simple projects can be a good way to figure out how
they work.

As best as I can tell, Hibernate is the current best of breed. It also
is not that hard to figure out - I was up and running on the first day
thanks to 'Hibernate in Action'.

Cayenne is a nice alternative to Hibernate, and it worked very well for
me. It was easier to autogenerate Hibernate descriptors than Cayenne
ones, but the Cayenne GUI tools were better, when last I checked. Since
you did not describe huge tables, this is probably not an issue either
way.

For the front end, you have a lot of choices. In rough order of ease of
use:

JSP is a Sun technology, based on tags on the page that turn into back
end java code. Fairly easy to learn, but it is really easy to stuff
java code on the page, and that is a big pain to maintain.

Tapestry is a very clean framework, but it takes a while to figure out.
It took me a few weeks before I was happy with what it was doing.
Howard Lewis Ship wrote a pretty good book, and it is under active
development. Frankly, I really liked Tapestry.

Spring seems to be what the market is moving towards, so it is worth
learning for that reason alone. I found it well architected for the
small project I was using it for, and it is on my current 'learn list'.
I seemed to be getting content out faster than with Tapestry, but it
seemed like building completely reusable components with Tapestry worked
better.

Good luck,

Scott
 
D

David Segall

I currently maintain a webiste at work that consists of mostly .jsps, a
few servlets, nothing super complicated. There's a front page on the
website that contains version info (version number, date of release),
and a short little news section with blurbs about new things going on
with the software available on this site. Also there are some release
notes pages that are updated with each new release as well.

What I'd like to do is make this front page, and maybe the release
notes page, more data driven, so that instead of having to go in with
each release and change the HTML/JSP pages, it can just pull this info
from a few tables in a database. We use SQL Server, so I'd be creating
the database there, and like I said, I don't think it's anything real
complicated, it's just I've never done it before, and I'm having a hard
time putting what I want into words enough so that I can find articles
or whatever on doing this.

Can anyone give me a head start, maybe point me to some tutorials or
sites on doing this, recommend any books, etc, or really any sort of
help?
I would try the easy way and get Studio Creator to write most of it
for you. The display part uses Java Server Faces. You can read about
it and download it from here
<http://developers.sun.com/prodtech/javatools/jscreator/ea/jsc2/>
 
C

CodeFutures

I suggest you keep it very simple and I'll try to keep my suggestion as
straightfoward as possible.

You're using SQL Server and you're creating a database. You want a JSP
front end.

What you're missing is the middle tier - that connects the JSP front
end with the database back end.

I suggest that you use the Data Access Object -DAO design pattern (see
http://www.codefutures.com/data-access-object).

You can use the database schema to automatically generate JDBC DAOs
(and all related code). There are tools to do this.....

Regards
PJ

PJ Murrray
CodeFutures Software
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top