| Author |
HttpSession get and setAttribute problem
|
raj guntupalli
Greenhorn
Joined: Dec 16, 2002
Posts: 27
|
|
I feel rather strange that my program recognises HttpSession but not its two methods.can anyone help me out.Heres the code. [ January 14, 2003: Message edited by: Cindy Glass ]
|
 |
Dominic Paquette
Ranch Hand
Joined: Dec 13, 2002
Posts: 64
|
|
Hi, I don't understand the question, what do you mean by "my program recognises HttpSession but not its two methods" ? Dominic
|
 |
Susil Parida
Greenhorn
Joined: Jan 09, 2003
Posts: 9
|
|
Hi, Your server's servlet API may be older than 2.2 . Try with getValue() and setValue() It will work. Regards Susil
|
Susil Parida<br />HCL Technologies<br />Susil_pp@epatra.com
|
 |
raj guntupalli
Greenhorn
Joined: Dec 16, 2002
Posts: 27
|
|
hi thanx but still it does not work..It gives me two errors 1)cannot resolve symbol method getAttribute() (or getValue) 2)cannot resolve symbol method setAttribute() (or setValue()).
|
 |
Sam Dalton
Author
Ranch Hand
Joined: Jul 26, 2001
Posts: 170
|
|
Originally posted by raj guntupalli: hi thanx but still it does not work..It gives me two errors 1)cannot resolve symbol method getAttribute() (or getValue) 2)cannot resolve symbol method setAttribute() (or setValue()).
Can you give us some more details? a) What web container are you using, and in particular which version? b) When do you recieve this error? At compilation or run time? Cheers Sam
|
<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
|
 |
Asher Tarnopolski
Ranch Hand
Joined: Jul 28, 2001
Posts: 260
|
|
your code was compiled without any problem. so, copy the fulle error message you get and post it here... may be we'll be able to learn something from it.
|
Asher Tarnopolski
SCJP,SCWCD
|
 |
Mark Howard
Ranch Hand
Joined: Feb 14, 2001
Posts: 285
|
|
Hi Raj I ran your code exactly as you posted it and it worked fine for me. I can only assume that there is some environmental hassle. I'm also a bit confused by your HttpSession being recognised but not it's methods? Is this at compile-time or run-time? Mark.
|
 |
raj guntupalli
Greenhorn
Joined: Dec 16, 2002
Posts: 27
|
|
Hi, I am getting the problem at compile time.All other servlets are working fine but I have only problem with this program.I am using tomacat 4.0.1 as my server and the servlet.jar file I used in ext of jdk1.3.1 jre is from jsdk1.2.Thanx for your help guys.
|
 |
raj guntupalli
Greenhorn
Joined: Dec 16, 2002
Posts: 27
|
|
C:\Program Files\Apache Tomcat 4.0\webapps\esession\HttpSession1.java:13: cannot resolve symbol symbol : method getAttribute (java.lang.String) location: interface javax.servlet.http.HttpSession List listOfItems=(List)session.getAttribute("listofitems"); ^ C:\Program Files\Apache Tomcat 4.0\webapps\esession\HttpSession1.java:17: cannot resolve symbol symbol : method setValue (java.lang.String,java.util.List) location: interface javax.servlet.http.HttpSession session.setValue("listofitems",listOfItems); ^ 2 errors Process completed. esession is a ordinary folder in webapps.Thanx
|
 |
DC Dalton
Ranch Hand
Joined: May 28, 2001
Posts: 287
|
|
First of all you are using session methods from 2 different APIs. getValue() & putValue() have been deprecated & you should now use getAttribute() & setAttribute()...if your using the newest API, if not use the first two. What is odd is that one of the two should work, depending on which API you are using, so you should only get one compiler error. I ran the code thru my machine with no compiler errors at all....I have to agree that either something is wrong with your environment or you may just have a corrupt servlet.jar. (Stranger things have happened) If you want to get a new one Ive uploaded mine to www.dcddesigns.com/servlet.jar that way you can get to it in a browser, download it & override yours. You might want to try that......
|
 |
Malhar Barai
Author
Ranch Hand
Joined: Aug 17, 2001
Posts: 399
|
|
Originally posted by raj guntupalli: C:\Program Files\Apache Tomcat 4.0\webapps\esession\HttpSession1.java:13: cannot resolve symbol symbol : method getAttribute ( java.lang.String) location: interface javax.servlet.http.HttpSession List listOfItems=(List)session.getAttribute("listofitems"); ^ C:\Program Files\Apache Tomcat 4.0\webapps\esession\HttpSession1.java:17: cannot resolve symbol symbol : method setValue ( java.lang.String, java.util.List) location: interface javax.servlet.http.HttpSession session.setValue("listofitems",listOfItems); ^ 2 errors Process completed. esession is a ordinary folder in webapps.Thanx
hi dear the problem is with your LIST & not SESSION...just check out the docs for list on java.util.List MB [ January 09, 2003: Message edited by: Malhar Barai ]
|
Malhar Barai
SOA & Java Book
|
 |
raj guntupalli
Greenhorn
Joined: Dec 16, 2002
Posts: 27
|
|
|
Thank you very much.As you have said I had the problem with servlet.jar.After Downloading the servlet.jar from you and replacing it the program compiles fine.Thank you very much once again.Bye
|
 |
 |
|
|
subject: HttpSession get and setAttribute problem
|
|
|