Generate JSPs from SQL query

Hello all,

I am currently creating a web application that will allow a user to create a homepage from a template that is displayed to them. If the user is logging into the system for the first time, the template to create their homepage is displayed to them. However, if the user is logging in and has already used the template to set their homepage options, they are then forwarded to their homepage.

The users options for their homepage are stored in a database. The problem I am having is trying to generate the jsp page ( with HTML inside also ) using SQL statements that query the table that store the users options.

Eg. an SQL query queries the DB to see wht options the user has selected. Can anyone help me / advise me how to use these queries to generate the homepage. Thanks in advance!

[822 byte] By [Jodie1981a] at [2007-10-2 14:30:58]
# 1
Once you fetch the user options, it's your wish how you want to create the display logic. You may make use of scriptlets for conditional generation, which are simple for small pages but the code could get bloated. The preferred approach is to make use of JSTL tags for conditional
aniseeda at 2007-7-13 12:52:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi aniseed,

Thanks for a prompt reply.

So for example can you tell me if the following sample approach is ok.

<html>

<head>

<body>

.

.

.

.

<sql:query name="query">

SELECT * FROM SettingsTable WHERE links == "yes"

</sql:query>

<%-- Then to use this query result to insert selected hyperlinks that the user wants in their homepage, I would do the following ....... ?--%>

<% if (query.size() == 0)

<table>

<td>

<tr>

<a href="...........">

</tr>

</td>

</table>

%>

Thanks again

Jodie1981a at 2007-7-13 12:52:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...