This tag used to execute the Select Statement in JSTL and stored value in variable.

This tag <sql:Query> used to implement or execute the select statement of sql Query. First we made a database named ‘dbase’ and table with required fields named ‘worker’ that will use to execute or linked with the front end. And all the drivers and attributes are also declared that will create a bridge between database and the coding as res. The query will fetch complete table in the program that will be presented on the web browser.


<%@ taglib uri="" prefix="c"%>

<%@ taglib uri="" prefix="sql"%>



     <title>&lt;sql:query&gt;Jstl Tag</title>



     <sql:setDataSource var="db" driver="com.mysql.jdbc.Driver"

     url="jdbc:mysql://localhost/dbase" user="root" password="root"/>

       <sql:query var="dt" dataSource="${db}">

          select * from worker


        <table border="1">







              <c:forEach var="values" items="${dt.rows}">











        JSTL SQL <sql:query> Tag

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.