struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Preetham Mallavarapu <preethamreddy.mallaar...@gmail.com>
Subject Re: Need help in fixing issue with Url refresh
Date Tue, 09 Jun 2015 15:49:19 GMT
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.Nenning@lex-com.net> wrote:

> > From: Preetham Mallavarapu <preethamreddy.mallaarapu@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.mallaarapu@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.Nenning@lex-com.net> wrote:
> > >
> > >> > From: Preetham Mallavarapu <preethamreddy.mallaarapu@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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message