• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass value to jstl within a jsp

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I need to pass the above value in below tag.
values are there in hiddenvalue, but if i use ${param.hiddenvalue} it is not recognizing the value and tried in many options.


Please suggest how to pass the value?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the relationship between these statements? Are they in the same JSP file? If not how are they related?
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes..both are in same jsp file
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, then param isn't going to contain anything. param contains submitted information. And if the form hash;t been submitted yet...

If the scoped variable user is in session scope, then ${user} will fetch it.

Why are you using a scriptlet expression rather than the JSTL in the first place?
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session is having value.

Could you please tel how to pass into <c:value=""> using jstl?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already told you: ${user}
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..

Is there is any way to use ${user} without using <%= session.getAttirbute("user")> ?
Because session is already available in the page..

Have to avoid getting session.getAttirbute("user").
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes: ${user}

Just ${user}

Always ${user}

Use ${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

${user}

Just ${user}

There is no need to include the scriptlet. Ever.

Why aren't you just trying it instead of posting questions?
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${user} is approximately equivalent to session.getAttribute("user") (it's actually pageContext.findAttribute("user") )
Maybe to make it explicit: Try ${sessionScope.user}

In any case, yes, you can access session attributes from JSTL.
There is no point in taking a value from session, putting it into a hidden field and getting it into JSTL via a request parameter when you can just read it from the session in the first place.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!