i am creating an email system Project. for which i nam taking an username and Password from one servlet. and i want to pass this username to another . so, i started using ServletContext class and getServletContext () Method . but i am getting error because its taking null value. can , anyone pls help me thank u
basically i depending on user to click the button.
what i have done is , i have created a servlet page for login. which in turn shows the Inbox button after ur logged in . this Inbox calls another Servlet which shows the EMails. but i am not able to get login username to inbox servlet . so, it doesnt depend on user login for showing different inboxs for differnt logins . and i am new in using ServletContext class. so, i have doubts regarding using it. like should we use HttpSession for creating a session. after creating this session when i say HtttpSession.getAttribute("String"); it is showing method not Found. so, pls tell me how to use it exactly
If I understand your requirements, Once user is logged in, For any subsequent clicks, you need to remember the user id and password?. If this is your requirement, I strongly suggest you to store userid and password in session or to make it more secure and object oriented, create class, which has String userId char password [Note password is char array because Strings are immutable. There is security risk involved in storing passowrd in String.]
Store this class in HttpSession object. This is more efficent than storing user id and password as two separate object in session.
How are you calling request.getSession(). Please pass in the false, So it uses already created session or you will get null session, so you can create new session. I hope this helps you...
after creating this session when i say HtttpSession.getAttribute("String"); it is showing method not Found. so, pls tell me how to use it exactly
Assuming that you've named your request "request" in the doPost signature..
Then, to retrieve it...
Joined: Oct 24, 2004
the problem is that whenever i use request.getRequestDispatcher("some string"); or request.getAttribute(""); or any method i call by request i am getting an error like method not found . i am using JSDK2.0 is that something to do with the errors or coding is error
it is saying cannot resolve the symbol symbol: method getRequestDispatcher(string);
thank u once again....
Joined: Nov 13, 2002
You got me there... I even tried to copy/paste your code, and it compiled fine on my environment.
The only (far-fetched) possibilities I'd check for: - typing errors - could there be another class called "ServletContext" , somewhere in your classpath ? You mihgt like to change the delcaration to the fully qualified class name:
Of course, these are far fetched... but I simply can't imagine any other reason that would cause the problem. Very strange indeed.
may be i have a problem in setting the path becoz if i change some semicolons in the path , while compiling it is telling RequestDispatcher method not found , the i again changed it back to normal then it is saying ServletContext.setAttribute method not found....
i am setting the path as follows :
set path=d:\j2sdk1.4.1_02\bin;d:\jsdk2.1;d:\JSDK2.0\bin;d:\j2sdkee1.2.1\bin; set CLASSPATH=d:\j2sdk1.4.1_02\lib\src.jar;d:\JSDK2.0\lib\jsdk.jar;d:\jsdk2.1\servlet.jar;d:\j2sdkee1.2.1\lib\j2ee.jar;