Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get sessionscope boolean varible  RSS feed

 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my jsp


when i run it it prints otherwise alwayssssssssss.
why it is not printing trueeeeeeee.
 
Marshal
Posts: 5923
874
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Samanthi perera wrote:when i run it it prints otherwise alwayssssssssss.


Please UseRealWords.
And again again again, you should NOT place those Scriptlets in JSPs.
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:



set your attribute in the servlet, not in the jsp.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya .it is working.thanks .
anyway why otherway is not working.
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because it's not the right way to access sessionScope object where your check variable resides.

 
Devaka Cooray
Marshal
Posts: 5923
874
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Samanthi perera wrote:why otherway is not working.


In EL, anything you placed within the square-brackets in considered as an expression.
In particular, it works if you placed "check" as a String value: ${sessionScope["check"]}
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, use Boolean.TRUE, and simplify the conditional to ${session["check"]}. As mentioned previously.
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!