aspose file tools*
The moose likes JSP and the fly likes Using JSTL in scriplets - compile error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using JSTL in scriplets - compile error" Watch "Using JSTL in scriplets - compile error" New topic
Author

Using JSTL in scriplets - compile error

Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

Just like any other tags, you cannot embed JSTL tags in scriptlet code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Apr 19, 2005
Posts: 70
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.


Satish SN<br />SCJP 1.4 & SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using JSTL in scriplets - compile error