I am trying to use a session that I have made in JSP in a sql statement. But having difficulties.
I captured it already and this is the SQL statement I made, but doesnt work.
String mysql="select * from table1 where cottCode="<%= session.getAttribute( "theName" ) %>"";
Any help appreciated, thank you.
I think here you are trying to do things like this:
This kind of code is called JSP Scriptlet.
However, expressions like :
are called JSP Expressions.They are used to “insert the value of a scripting language expression, converted into a string, into the data stream returned to the client. ” Like this:
So I don’t think you can use the expression in the middle of scriptlet. Here is the tutorial on related topics, hope it’ll help:
The Java EE 5 Tutorial