This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSP and the fly likes getting variable value Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "getting variable value" Watch "getting variable value" New topic
Author

getting variable value

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
i can set the varible value using
<c:set var=”userLevel” scope=”session” value=”Cowboy” />

but how to get the value of userLevel?
I tried
${sessionscope.userLevel}
${userLevel}

but all are not working
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


What c:out is for ?
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
this is my jsp .But it don't print any value

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


[quote]<c:out value='userLevel' default='guest' /> [/quote]

This is not right. How do you print EL in c:out ? Its pretty much the same way.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
then how .
please tell me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

aruna sameera wrote:
${sessionscope.userLevel}
${userLevel}

Case counts. It's sessionScope.

The other should have worked. What are you seeing in the rendered HTML?

P.S. <c:out> is not necessary unless you want the output HTML-encoded.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
${sessionScope.userLevel} is working
but <cut value="userLevel" default='guest' /> gives nothing
whta happen ?
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 356
yes ,
I also tried.
AppView.jsp


for only ${sessionScope.userLevel} it is working.
when I try to do for above jsp it thowing following exception,




Thanks,
Shailesh
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 356
but <cut value="userLevel" default='guest' /> gives nothing


for this it is giving userLevel as output.

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
yes .
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
soory for the mistake

this prints userLevel


this prints Cowboyl


my queation how to print this value using cut;
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Aruna,

What does <cut value="${userLevel}" /> prints ?
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
I change my jsp to this.



then it give this
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

That usually means that you are mixing versions that are not compatible. What versions of JSP, and the JSTL are you using?

P.S. You are using a JSTL 1.0 URI.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
what is that mean?
how could i find which version of JSTL i am using ?
what are the limitation of that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

Please read through the JSP FAQ. If you don't even know what versions of software you are using, you need to buckle down and figure all that out.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
is it true that jstl 1.2 doesn't need standered.jar file?
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
now it is working.it gives output as
Cowboy
Cowboy
Cowboy

here is the code

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 692
Bear Bibeault ,Balu Sadhasivam
Thanks for helping
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

aruna sameera wrote:is it true that jstl 1.2 doesn't need standered.jar file?


Yes if you download and see the files inside the jstl 1.2 jar , it contains tag handlers as well as tld files all inside single jar.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: getting variable value
 
Similar Threads
Default scope fpr <c:set ?
What if the value is null and the var does not exist in the particular scope for c : set?
JSTL doubt
HFSJ pg 445 c:set
c:set