| Author |
Session related error
|
Nelo Angelo
Ranch Hand
Joined: Jul 25, 2011
Posts: 44
|
|
Hello,
I am not able to create session for my Servlet. I was initially trying to session the captcha code but found continuous errors with "setAttribute". So I tried a very simple program but still the same error pops ups. Please help.
With the above code I get the following error:
cannot find symbol
symbol: method setAttribute(java.lang.String,java.lang.String)
location: interface javax.servlet.http.HttpSession
|
I love java but she hates me... :'(
|
 |
Jk Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 159
|
|
|
You have a misspelling in line 2.
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1503
|
|
|
Line 2 should be import javax.servlet.http.*; I am surprised you did not get a syntax error.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Nelo Angelo
Ranch Hand
Joined: Jul 25, 2011
Posts: 44
|
|
Thanks for the replies, but that's not the problem. I didn't copy paste the code here and its just a typo here. The package name has been written correctly in the code and the same error keeps on showing. I also checked the servlet-api.jar for classes and it contains all that are required. Have checked the environment variables for classpath issues, none found.
Is it possible that my compiler is not functioning correctly? Any suggestions?
|
 |
Nelo Angelo
Ranch Hand
Joined: Jul 25, 2011
Posts: 44
|
|
I hope that everything in the doPost() body is correct.
The compiler specially points out to the setAttribute() method.
Also, if I remove "true" in HttpSession session=request.getSession(true); I get an error something like this:
getSession(boolean) in javax.servlet.http.HttpServletRequest cannot be applied to ().
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18370
|
|
|
Where did you get that servlet-api.jar file from? Because if that's correctly part of the class path, it's got wrong versions of classes / interfaces in them if it can't find these methods.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Session related error
|
|
|