Build dynamic sql query for JSTL <sql:query>

A

Anonymous

Hi,

I am using JSTL to build JSP pages. Depending on input parameters, I
want the JSP pages to query a database based on different SQL queries.

For example, instead of using the following hard-coded-in "Select"
query, I want to build the "Select *** from ***" statement dynamically.

<sql:query var="grs" dataSource="jdbc/testdb">
select distinct group_name from user_groups order by group_name
</sql:query>


For example, I'd to change above sql:query to the following example:

<% String qry= "select distinct group_name from user_groups order by
group_name
";%>

<sql:query var="grs" dataSource="jdbc/testdb">
qry
</sql:query>


Is this possible?

Thanks,
 

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,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top