?
Solved

get boolean from servlet session

Posted on 2000-04-19
14
Medium Priority
?
224 Views
Last Modified: 2013-11-24
I've saved boolean:

session.putValue("check_2",new Boolean(check_1));

how can I get the value ?

that doesnt work:
session.getValue("check_2")
0
Comment
Question by:smike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 4
14 Comments
 
LVL 4

Expert Comment

by:jerch
ID: 2730079
Hi smike...
Boolean b = (Boolean) session.getValue("check_2");

You have to type cast it back since getValue returns an Object type.

Jerson
0
 
LVL 1

Expert Comment

by:dmaguillo
ID: 2730142
Hi smike.

In version 2.2, getValue and setValue are deprecated in favor of getAttribute and setAttribute (u could try these).

Bye... :)
0
 

Author Comment

by:smike
ID: 2730395
Adjusted points from 50 to 75
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:smike
ID: 2730396
Quest.java:118: Invalid cast from java.lang.Object to boolean.
    boolean b2 = (boolean) session.getValue("check_2");
0
 
LVL 4

Expert Comment

by:jerch
ID: 2730411
No... try Boolean with a capital B.

Jerson
0
 

Author Comment

by:smike
ID: 2730711
I have tried it. I cant use Boolean in "if"

Quest.java:120: Incompatible type for if. Can't convert java.lang.Boolean to boolean.
    if (b2) {
0
 
LVL 1

Expert Comment

by:dmaguillo
ID: 2730765
Hi smike.

Try it:

boolean b = Boolean.getBoolean((session.getValue("check_2")).toString());
0
 

Author Comment

by:smike
ID: 2730865
it worked,
but how to get value of integer "amount" ?


session.putValue("amount",new Integer(amount));
0
 
LVL 4

Expert Comment

by:jerch
ID: 2730917
hi smike...
You can use the booleanValue() method of Boolean.

e.g.

Boolean b2 = (Boolean) session.getValue("check_2");

if (b2.booleanValue()) {
}

cheers...
Jerson


0
 
LVL 4

Expert Comment

by:jerch
ID: 2730933
Hi smike...
Use the intValue() method of the Integer.  By the way try to download the Java API documentation? It lists all the available classes and methods of those classes of the Core Java.


Jerson
0
 
LVL 1

Expert Comment

by:dmaguillo
ID: 2730934
U have a similar class named "java.lang.Integer":

int i = Integer.parseInt((session.getValue("amount")).toString());

0
 
LVL 1

Expert Comment

by:dmaguillo
ID: 2730939
U have a similar class named "java.lang.Integer":

int i = Integer.parseInt((session.getValue("amount")).toString());

0
 

Author Comment

by:smike
ID: 2732114
where to download Java API ?
0
 
LVL 4

Accepted Solution

by:
jerch earned 225 total points
ID: 2733059
0

Featured Post

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question