Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSession get and setAttribute problem

 
raj guntupalli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your server's servlet API may be older than 2.2 . Try with getValue() and setValue()
It will work.
Regards
Susil
 
raj guntupalli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
raj guntupalli
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic