• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session related error

 
Nelo Angelo
Ranch Hand
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a misspelling in line 2.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 2 should be import javax.servlet.http.*; I am surprised you did not get a syntax error.
 
Nelo Angelo
Ranch Hand
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic