• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

change password

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i have an option on my web page of forget password & change passwod for that i need that on my action form my login name should be used as session but the problem is how can i use sessions please help me i dont know much aboout sessions

thank you
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aditi,

Can you put some light on your requirement, and please add some code that you tried to implement this, that will help ranchers to come up with some solution for you.

Thanks,
Shailesh
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Shailesh

actually i want that user can change their password if they forgot or if they want to change the password but without mentionaing loginname that loginname should be passed through the sessions now i want how to use sessions & at what place & in what manner

my userLogin.jsp page is



userloginaction


changepasswrod.jsp




changepasswordaction

 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In userloginaction you can put userName in session(you can get session object from request which is parameter to execute method )if user id & password is validated.
Then in your changepasswrod.jsp you can retrieve it from session (In jsp we are having implicit session object).

HTH
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply but problem with me is how to do that

i dont kno how to use the sessions

thank you
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you help me in that

thank you
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aditi,

you can get help of API for HttpServletRequest on this link.
(you can use getSession() method of HttpServletRequest object.)

for HttpSession you will get at this link.
(you can use getAttribute & setAtttibute method of session object.)
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply shailesh
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one thing more i have tried

please have a look over it is it correct or not

if any modifications please let me know


in userloginaction.java
String username=userLoginForm.getUsername().trim();
HttpSession session=request.getSession(false);
session.setAttribute("user", "username");

in changepasswordaction.java

String user=session.getattribute("username");

one more thing ho wto invalidate it because when i have used it earlier
my whole application stop working

thank you
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably need a type cast here, because return type of getAttribute is Object.



And you should store the value of username

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnks swastik for your reply

actually ihave used this only but by mistake written wrong

but this is still not working on my page
what should i do now
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By not working on my page, what do you mean? What is happening or what is going wrong?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have used this code on my userloginaction.java



now on changepasswordaction.java


i have made nothing on my changepasswd.jsp

now when i hve done this all & run my page then its goin towrads failure

help me
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Failure from userloginaction or changepasswordaction?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually when i click on changepassword link then jsp page open i can fill all the fields in changepassword.jsp
but as soon as i click on submit then it goes to failure

i think its due to i have not declared or used for session on my changepassword.jsp
please help me what should i do

thank you
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you need to declare session in jsp, because action is being handled by the action handler class.
What is happening here?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the correct changepassword action



i have updated it now here

now if any mistake then tell me
thank you
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to be ok now, are you getting the correct output?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
output kahan se abhi to form run nhn kar rha hai i think i have done asimple mistake

can you do me afvour

i am posting here my userloginaction
please check it


changepasswordaction



if i have done a blunder then please ley me know

thank you o much
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you made any change in either of the two codes? And by the way you still have this problem



"user"?? it should be the variable name.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes swastik i still have the same problem



these lines are creatng session & then user is the variable with username as its value

in following code


i am getting my session in a new variable user to be used in my changepaswword.jsp page
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your reply swastik "user" taking null
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aditi,

First of all go through getAttrubute() & setAttribute() method of HttpSession object.

in that setAttribute() first parameter is name of attribute and second parameter is object that you want to put in session.

above code will not work because you are setting string "username" in session with name as user.
So if you call you will get String object "username" in reply.

do setting attribute by following code,


and for getting from session





 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much shailesh it worked now i am getting no error now & my form is working at its best

thank you so much

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but now one problem starts my form is not logging in
tell me one thing how to invalidate sessions

if you have any tutorials then let me know please
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say again go through HttpSession methods there is one method to invalidate session.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you shailesh i have read your page link & also i have invalidate my session but still my form is not allowing me to login

can you please help me why is it so
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Not allowing me to login

, so what is exactly happening when you click submit?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now when i click my submit button my page remains over there only it dont proceed to anywhere
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What changes have you made in userloginaction? One more thing I could not figure out what has invalidate got to do with login? Invalidate is typically used when you no longer wish to hold the session, so a typical situation can be when the user logs out. Apart from this have you made any change in the login jsp page?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yipeee my form worked automatically & it working fyn

thank you swastik & shailesh

 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great job. So it's done at last.
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic