• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using JSTL in scriplets - compile error

 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning JSTL and find useful using c:sql tag. But if I use it in
JSP pages that have function declaration like below I get comiple error. Are we not allowed to use JSTL in Java code. Reallyn when I look at java fiel in work directory it seems compile error.:

<%!
String convertResultsToSelect () throws SQLException
{
<sql:setDataSource var="example" scope="application"
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc racle:thin:@locathost:8080 rcl"
user="scott"
password="tiger"
/>
<sql:query dataSource="${example}" var="empList" scope="request">
SELECT * FROM test_object

</sql:query>

return "sb";
}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just like any other tags, you cannot embed JSTL tags in scriptlet code.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moreover, JSTL meant to avoid the use of scriplets. Use as less scriptlets as you can. Most of the time we dont need those classic scriplets.
 
Satish SN
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh

Infact JSTL was developed to make the view (JSP) make it readable and also to keep it clean from the usual scriplet logic for that they provided some tag-libs for doing normal if,for and also logical operations along with sql operations infact i found out that it is still evolving and we can expect some more useful tags.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic