Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session.setAttribute

Status
Not open for further replies.

funyman

Programmer
Sep 20, 2000
13
CA
Hi All,

I really don't know what is going on ...

I'm developing servlet with jdk1.3 and using tomcat as server. I can't compile my code b'cos i'm getting the following error
Method setAttribute(java.lang.string,java.lang.string)not found in javax.servlet.http.HttpSession
WHY ???

my code can be as simple as that
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
HttpSession session = req.getSession(true);
session.setAttribute("test","test");
}
any ideas ???
thx
funyman
 
I expect your servlet.jar is the Servlet API 2.1 - which does not the contain setAttribute() method.
When Servlet API 2.2 came out, this setAttribute() method was provided.

I would either upgrade your servlet.jar, or use the 2.1 method of putValue(String s, Object o). Mind though, this method was deprecated as of 2.2.

Ben
 
I was wondering how the javac sees this servlet.jar. Is it specified in the classpath env var?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top