| Author |
Compilation Error
|
Ravissant Markenday
Ranch Hand
Joined: Nov 12, 2006
Posts: 47
|
|
hi everyone! im getting this error while compiling a servlet: SessionLifeCycleServlet.java:88: setAttribute(java.lang.String,java.lang.Object in javax.servlet.http.HttpSession cannot be applied to (java.lang.String) session.setAttribute(fname); ^ Could anyone please tell me what it means and what i can do to fix it? Thanks in advance, Ravissant Markenday
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
I think you're missing a parameter. You have to provide a name/value pair to the setAttribute method. session.setAttribute("First Name", fname); Here's a tutorial on using the HttpSession object, along with some sample code: Free Tutorial on How to Use the HttpSession Object in a J2EE Application Happy Java! -Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
Any setAttribute method will accept two parameters. both are of type Object. But you are passing only one parameter. Make it two(both should of type Object).
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by Prabhu Venkatachalam: Any setAttribute method will accept two parameters. both are of type Object. But you are passing only one parameter. Make it two(both should of type Object).
Not entirely true. The setAttribute method does take two arguments but the first is java.lang.String. See: java.lang.String,%20java.lang.Object)" target="_blank" rel="nofollow">http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html#setAttribute(java.lang.String,%20java.lang.Object)
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Ravissant Markenday
Ranch Hand
Joined: Nov 12, 2006
Posts: 47
|
|
|
Thanks Cameron, Prabhu and Ben !!!
|
 |
 |
|
|
subject: Compilation Error
|
|
|