Hello People,
How can I write html or JSTL tags in Java Scriplets? I have done a sql query using JSTL tags now I want to have assign the results to string in java scriplets as show below but I am getting an error. Please how can I achieve this? How can I solve this problem? Please help.
The error I am getting is as follows:
An error occurred at line: 46 in the jsp file: /Income/hook/Status/tatus2.jsp
Syntax error on token “$”, delete this token
Please give an example of connecting to the database if possible and then use String id = (String) row.get(“id”); I I am trying something like below and but is not working
DAO dcon=new DAO();
ResultSet searchView=dcon.GetTransaction();
I think you’ve missed the point of what a scriptlet is. Anything inside the <% %> is considered Java and will be compiled as Java. So <c : out /> won’t compile since it’s not Java.
I would avoid using scriptlets altogether and set the variables using <c : set />. You can search <c : set /> on google for proper usage. Or if you are going to use scriptlets, you need to do get the row variable from the page scope, and I’m not even sure what type of Object that is, which would then have an id attribute. Let’s say it’s a Map, but it might not be, if it’s not you’ll get a ClassCastException:
Map row = (Map) pageContext.getAttribute("row");
String id = (String) row.get("id");
// same for the others
Hopefully this shows why you shouldn’t use scriptlets.