aspose file tools*
The moose likes Servlets and the fly likes Session related error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session related error" Watch "Session related error" New topic
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... :'(
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1043
    
  13

You have a misspelling in line 2.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
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
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session related error