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="location">login.jsp</param> > </result> > > <result name="studentHomePage" type="redirectAction"> > <param name="actionName">displayManager</param> > </result> > </action> > <action name="displayManager" class="com.project.manager.DisplayManager"> > <result name="success">student/studentHomePage.jsp</result> > </action> > > <action name="*RegistrationManager" > class="com.project.manager.RegistrationManager" method="{1}"> > > > <result name="displayLoginPage">login.jsp</result> > <result name="newUserRegistrationFailed">signup.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 displays user first name but when I try > > using > > > redirectAction it shows *"firstName" instead of data..* > > > > > > I am not sure whether I have followed the correct process or not.. > > > > > > could you kindly provide me an example where I can refer ..? > > > > > > Thanks, > > > Hari Krishna > > > > > > > > > You can have a look at this CRUD sample: > > > > https://github.com/wolpi/struts2-crud-sample/tree/master/struts2- > crud-sample/src/main/java/test/crudsample/actions > > > > Do you have just one action which handles all your pages or do you have > > two different actions? > > After a redirect you must load data from database. > > > > > > Regards, > > Christoph > > > > > > > > > > > > > > > On Mon, Jun 8, 2015 at 7:42 PM, Preetham Mallavarapu < > > > preethamreddy.mallaar...@gmail.com> wrote: > > > > > > > Thanks Christoph for the suggestion. I will give a try now. > > > > > > > > Thanks, > > > > Hari Krishna > > > > > > > > > > > > On Mon, Jun 8, 2015 at 4:25 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: 08.06.2015 11:00 > > > >> > Subject: Need help in fixing issue with Url refresh > > > >> > > > > >> > Hi, > > > >> > > > > >> > I have a problem in my struts2 app when I try to refresh url > > > >> > > > > >> > Below is the url I am trying to refresh.. > > > >> > > > > >> > when user logs in then the *checkUser* method will be called in the > > > >> > LoginManager class and if it is a successfull login the home page > > will > > > >> be > > > >> > called having the below one as the url.. > > > >> > > > > >> > http://localhost:8081/NewApp/checkUserLoginManager > > > >> > > > > >> > > > > >> > Now the problem is when I try to refresh the url it throws me null > > > >> pointer > > > >> > exception..for me it looks like it is calling again the checkUser > > > >> method.. > > > >> > > > > >> > Now can someone help me on how to fix this? > > > >> > > > > >> > Thanks, > > > >> > Hari Krishna > > > >> > > > >> > > > >> hi, > > > >> > > > >> this sounds like you don't use a redirect but answer the > > > >> login-post-request with html. When an user hits browser refresh the > > post > > > >> request ist submitted again but the action misses some data at this > > time. > > > >> I suggest to use a redirect after login to show the user start page. > > > >> > > > >> > > > >> http://struts.apache.org/docs/redirect-action-result.html > > > >> > > > >> > > > >> regards, > > > >> Christoph > > > >> > > > >> > > > >> This Email was scanned by Sophos Anti Virus > > > >> > > > > > > > > > > > > This Email was scanned by Sophos Anti Virus > > This Email was scanned by Sophos Anti Virus