Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

EL language question

Thread view: 
Nicolas Laplante - 14 Sep 2006 04:12 GMT
Hi all,

I didn't find a suitable JSP newsgroup so I post my question here:

I have a tag that has an attribute "level" which is a numeric type
(integer).

I want to know if it's possible to use EL language to create the
equivalent of this:

[code]
String str = "";

for (int i = 0; i < level; i++) {
    str += "../";
}
[/code]

The methods in JSTL's core library (c) cannot do the trick as far as I
know, nor do the functionalities offered by the functions library (f).

Do I need to do it in a scriplet? If so, how can I access the "levels"
variable (which is an attribute of the custom tag) from the Java scriplet?

If you need any additional info, just ask! :)

Thank you,

Nicolas Laplante
Manish Pandit - 14 Sep 2006 04:39 GMT
Is this in line with what you need?

Make sure you do an isELIgnored="false" in your JSP on the @page
declaration.

<c:forEach var="i" begin="1" end="10">

     <c:set var="str" value="${str}../"/>

</c:forEach>

The result is : ${str}

-cheers,
Manish
Manish Pandit - 14 Sep 2006 04:47 GMT
Oh - just to add the level variable you mentioned - you can access it
by doing a ${level}, which will change the loop to:

<c:forEach var="i" begin="0" end="${level}">

      <c:set var="str" value="${str}../"/>

</c:forEach>

The result is : ${str}

Assuming level is a variable available in the page/request/session
scope. If you want you can even qualify the scope by
${requestScope.level} or ${sessionScope.level} or ${pageContext.level}
based on where it is.

-cheers,
Manish
Nicolas Laplante - 14 Sep 2006 12:53 GMT
> Oh - just to add the level variable you mentioned - you can access it
> by doing a ${level}, which will change the loop to:
[quoted text clipped - 14 lines]
> -cheers,
> Manish

Thank you very much for your help! I must have misread the JSTL
documentation then :)

Nicolas Laplante
Mark Space - 14 Sep 2006 20:32 GMT
> Thank you very much for your help! I must have misread the JSTL
> documentation then :)
>
> Nicolas Laplante

Not that I really think anyone here minds EL questions, but there is a
Tomcat mailing list.  Check the tomcat.apache.org page, there's a link
to it somewhere on there.  They can probably help you faster and better
than most people here can.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.