Results 1 to 11 of 11
  1. #1
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default JSTL c:set problem

    So for some reason when I set variables they just... don't exist O.o

    Some test code I wrote:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"%>


    <c:set var="period" value="1" scope="session" />
    <c:out value="${param.period}" />


    This just shows a blank page. I was using something similar in different code earlier and at one point I printed the variable, which worked, but now it won't print anything anymore, and when I use it in a constraint I get incorrect results. I can't see any syntax errors. Anybody know whats going on?

  2. #2
    jing-yi is offline Member
    Join Date
    May 2011
    Posts
    35
    Rep Power
    0

    Default

    Look like the uri value does not return xml file anymore.

    I think it is better for you to create one jstl xml file.

  3. #3
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default

    Thanks! Can you elaborate on how to do that?

  4. #4
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default

    Still confused, any more help would be great...

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    Have a read here.
    The URI is dependent on the version of the library you are using (see link).
    It's a marker, not a real location, used by the library.

  6. #6
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default

    Thanks for that Tolls. I'm not sure if that's the problem though, since my jstl sql statements are working fine.

    Also I added the following line to my code and it outputted 5 like it should:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>

    <c:set var="period" value="1" scope="session" />
    <c:out value="${param.period}" />
    <c:out value="${3+2}" />


    Then again I could have just misunderstood the link you sent me >.>

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    Actually, is that first c:out correct?
    You've just stored "period" in your session.
    Shouldn't that be "sessionScope.period" then?

  8. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    Also, as the link I posted says, you don't need to use c:out for EL.
    The EL will be translated anyway.

  9. #9
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default

    Oh... that worked! Apparently I need to brush up on my syntax >.>

    Thanks!

  10. #10
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    I should have spotted that sooner.
    I got distracted by jing-yi's point, which turned out to be a wrong turn...:)

  11. #11
    UnfairBear is offline Member
    Join Date
    Jul 2011
    Posts
    29
    Rep Power
    0

    Default

    Heh, I probably should have spotted it myself. ^_^ Thanks again

Similar Threads

  1. problem with jstl
    By pablos in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-19-2010, 07:28 AM
  2. Weird problem with JSTL
    By Diego_Dalmasso in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 03-02-2010, 02:51 PM
  3. Problem Running in Simple JSTL example
    By arpitgadle in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 06-28-2009, 09:19 PM
  4. JSTL problem
    By mihir66 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-05-2009, 02:28 PM
  5. Problem using jstl and displaytags
    By NikhilSrivastava in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-18-2008, 11:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •