wood burning stoves*
The moose likes JSP and the fly likes getting variable value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "getting variable value" Watch "getting variable value" New topic
Author

getting variable value

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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 ?
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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.
sam liyanage
Ranch Hand

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

Joined: Jan 10, 2002
Posts: 60774
    
  65

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.
sam liyanage
Ranch Hand

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

Joined: Jul 10, 2008
Posts: 368
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: 368
but <cut value="userLevel" default='guest' /> gives nothing


for this it is giving userLevel as output.

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
yes .
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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 ?
sam liyanage
Ranch Hand

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



then it give this
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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.
sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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: 60774
    
  65

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.
sam liyanage
Ranch Hand

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

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

here is the code

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1071
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: getting variable value
 
Similar Threads
HFSJ pg 445 c:set
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
c:set