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. Advertisements

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. Howard

    build sql query

    Howard, Sep 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,119
    Bruce Barker
    Sep 7, 2005
  2. shahbaz
    Replies:
    0
    Views:
    1,094
    shahbaz
    Oct 27, 2003
  3. Brent Eamer

    JSTL SQL tags and Javascript

    Brent Eamer, Dec 17, 2003, in forum: Java
    Replies:
    0
    Views:
    712
    Brent Eamer
    Dec 17, 2003
  4. Marie Griffiths Remove Rubbish

    jstl sql taglib database error codes

    Marie Griffiths Remove Rubbish, Apr 10, 2004, in forum: Java
    Replies:
    0
    Views:
    1,062
    Marie Griffiths Remove Rubbish
    Apr 10, 2004
  5. Robert Mark Bram

    Custom JSTL that accepts JSTL expression

    Robert Mark Bram, Dec 15, 2004, in forum: Java
    Replies:
    0
    Views:
    1,292
    Robert Mark Bram
    Dec 15, 2004
  6. Dancing Fingers

    Can't insert dynamic link using jstl

    Dancing Fingers, Mar 19, 2008, in forum: Java
    Replies:
    1
    Views:
    619
    Dancing Fingers
    Mar 19, 2008
  7. DaFoot
    Replies:
    1
    Views:
    2,046
    DaFoot
    Oct 23, 2008
  8. jonjon
    Replies:
    0
    Views:
    355
    jonjon
    Oct 29, 2003
Loading...