Web Hosting Talk







View Full Version : I'm totally confused over this one....


jackdavis
04-07-2003, 06:47 PM
Sorry about the subject but I don't know how to sum this problem into a short sentence.

Basially I'm building a small ecommerce app and I'm using JSP. I want to make it as dynamic as possible and not have much static details.

I will be selling products and I want to categorise them. So I have dynamically generated a list of categories from my db...

String name = RS.getString("name");

I have "href" each category as so....

td><a href="<%= response.encodeURL("subcategory.jsp") %>"><%= name %></a></td>


The idea is that each category listed is linked to 1 template page rather then having a sepearte page for each category. However the problem is how can I ensure that the category I click on gives me the that category's subcategories.

Basically this is my problem. I'm a total newbie so any help is much appreciated.

Thanks in advance

jb4mt
04-07-2003, 07:35 PM
Your solutions seem to be either:

1) store sub-category information in a new table in the database

2) hard-code a data structure for sub-categories into the java code itself

As to #2, you might want to create a HashMap, which is like an array but indexed by a string rather than incremental integers. The index, or key, could be the name of the category. The value for each key, in turn, could be a "traditional" array of string values, one for each subcategory.

The problem with solution #1 is all the database access not only for categories, but also subcategories. The problem with #2 is the inflexibility of storing all this data purely as Java code.

A third option might be XML.

hololi
04-08-2003, 09:46 AM
check out jsp "tiles" for dynamic content driven websites.

Also "struts" is a jsp web application development framework from the jakarta boys at apache

BTY Apache also do a native XML database called xindice. I use it and it's great

good luck
hololi