Build dynamic sql query for JSTL <sql:query>

Discussion in 'Java' started by Anonymous, Oct 13, 2005.

  1. Anonymous

    Anonymous Guest

    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,
    Anonymous, Oct 13, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shahbaz
    Replies:
    0
    Views:
    889
    shahbaz
    Oct 27, 2003
  2. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    956
    Robert Mark Bram
    Dec 15, 2004
  3. Dancing Fingers

    Can't insert dynamic link using jstl

    Dancing Fingers, Mar 19, 2008, in forum: Java
    Replies:
    1
    Views:
    437
    Dancing Fingers
    Mar 19, 2008
  4. DaFoot
    Replies:
    1
    Views:
    1,671
    DaFoot
    Oct 23, 2008
  5. jonjon
    Replies:
    0
    Views:
    199
    jonjon
    Oct 29, 2003
Loading...

Share This Page