Reputation: 79
Hello i have a a session value of the user id of the person that has just logged in and i am trying to use that value so that i can display the information from a database of that user and put them in a table.
Query:
<sql:query var="result" sql= "SELECT * FROM Customer WHere...... "/>
how can i make it so a session.getAttribute can be entered on the Where part of the query ? i am using jsp and mysql.
The rest of the code takes the result variable and then puts it in a table on the customer page.
Upvotes: 1
Views: 709
Reputation: 23226
Assuming your userId is in the session with the key 'userId' then like the below:
<sql:query var="result" sql= "SELECT * FROM Customer where id = ?">
<sql:param value="${userId}" />
</sql:query>
http://docs.oracle.com/javaee/5/tutorial/doc/bnald.html
Upvotes: 1