HI Christoph,
Sorry for the delayed response.
Thanks a lot for your assistance on this issue. Now its working for me.
My Classes are almost similar to what you said except that I was
redirecting to the home page from the login action which was causing the
issue. I have made tweaks in my code as per your suggestion and it
perfectly works now.
Tons of Thanks again.
Thanks,
Hari Krishna
On Wed, Jun 10, 2015 at 1:34 PM, Christoph Nenning
christoph.nenn...@lex-com.net wrote:
Hi,
well, I would create more files for that:
- LoginAction
- login.jsp
- LoginManager
- UserDataAction
- userData.jsp
And flow would be like this:
- Send GET request to LoginAction
- LoginAction uses some result to show login.jsp (e.g. dispatcher-result,
tiles, sitemesh, ...)
- login.jsp shows a login form
- when user submits that form a POST request is sent to LoginAction
- LoginAction uses LoginManager to check if user is valid
- LoginAction must somehow remember that user is logged in. It could put
an object in http-session or set a custom cookie, ...
- LoginAction redirects to UserDataAction (by using a redirect-result)
- This causes the Browser to send a new GET request to UserDataAction
- UserDataAction checks that user is logged in (by checking the session,
cookie, ...) and uses LoginManager to load user-data
- UserDataAction uses some result to show userData.jsp (again: e.g.
dispatch, tiles, sitemesh, ...)
- userData.jsp uses struts tags and OGNL to display user-data which has
been loaded into UserDataAction
That shows how the MVC-pattern is handled in struts:
- Action classes are controllers, all URLs point to actions
- Action classes use Logic classes (like LoginManager) and let them do
busines logic
- JSPs are just used for the View part, they are only invoked through
actions
It also shows how 'login to a web app' is usually done: by using session
or cookies.
Regards,
Christoph
From: Preetham Mallavarapu preethamreddy.mallaar...@gmail.com
To: Struts Users Mailing List user@struts.apache.org,
Date: 09.06.2015 17:49
Subject: Re: Need help in fixing issue with Url refresh
Hi Christoph,
Thanks for your quick response..I am briefing the issue once again..
The inital flow was like this before...
I have login.jsp(username and password) - checkUser
method(loginManager)-
Method calls a function in DB class and gets the user details if exist -
returns success to strus.xml - now user details gets displayed in UI
page..
here the url comes as said before..
http://localhost:8081/NewApp/checkUserLoginManager
and when I refresh it throws exception which might be due to calling the
checkUsermethod..
After the suggestion I have used a redirectAction
I have login.jsp(username and password) - checkUser
method(loginManager)-
Method calls a function in DB class and gets the user details if exist -
returns success to strus.xml -now I have used a redirect action to
another Action class which inturn redirects to homepage (but the problem
is
that it doesnt display the user details now) and the url issue got
fixed..
Now the url is like below
http://localhost:8081/ExamCentre/displayManager.action
Now if I try to move the login validation to second action, I am unclear
on
how to pass the data from login.jsp to the second action..
The project is in initial stage so I have 2 action class one for
registrtaion and one for login apart from the new one created for
redirection.
Below is my struts.xml for reference
action name=*LoginManager class=com.project.manager.LoginManager
method={1}
result name=displayLoginPage type=redirect
param name=locationlogin.jsp/param
/result
result name=studentHomePage type=redirectAction
param name=actionNamedisplayManager/param
/result
/action
action name=displayManager
class=com.project.manager.DisplayManager
result name=successstudent/studentHomePage.jsp/result
/action
action name=*RegistrationManager
class=com.project.manager.RegistrationManager method={1}
result name=displayLoginPagelogin.jsp/result
result
name=newUserRegistrationFailedsignup.jsp/result
/action
Thanks,
Hari Krishna
On Tue, Jun 9, 2015 at 8:10 PM, Christoph Nenning
christoph.nenn...@lex-com.net wrote:
From: Preetham Mallavarapu preethamreddy.mallaar...@gmail.com
To: Struts Users Mailing List user@struts.apache.org,
Date: 09.06.2015 16:27
Subject: Re: Need help in fixing issue with Url refresh
Hi Christoph,
I have tried working in the way login-post-request (using
redirectAction)..It successfully redirects to the required page but
its
not
displaying the data in that..
ex:
In jsP I have s:text name=firstName/
when I do without redirect it