Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:27:18+00:00 2026-06-08T03:27:18+00:00

I am using Struts2 in my application. In my application I have one login

  • 0

I am using Struts2 in my application. In my application I have one login form and one main page. On successful login, I call main page and inside that main page I have called another action. Up to this all is working fine and page is also display after successful login but when I press F5 or click on browser refresh button it will give me login page but I want the same page on which I fire F5 or refresh button. How can I achieve this, my struts.xml is as follow..

…

<action name="mytable" class="MyDataTable">

        <result name="success" type="json"/>            
        <result name="error">messages.jsp</result>

    </action>
    <action name="edit" class="MyEditAction">

        <result name="input" type="json"></result>
        <result name="success" type="json"></result>
        <result name="error">messages.jsp</result> 

    </action>
    <action name="Login" class="LoginAction">

        <result name="input">login.jsp</result>
        <result name="success">main.jsp</result>            
        <result name="error">messages.jsp</result>

    </action>
    <action name="Logout" class="LogoutAction"> 
        <result name="success">login.jsp</result>
    </action>

…

After login I call main.jsp and from main.jsp I am calling mytable action. After showing me the main page the address bar of browser still shows me the Login action

So please help me how can I maintain session.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:27:19+00:00Added an answer on June 8, 2026 at 3:27 am

    First of all, you must consider using a security framework. I recommend using Spring Security. There is A LOT that you can do wrong implementing security all by yourself. This will make sure users are properly authenticated and will guard you from many attacks. From the code you give us, it doesn’t seem that you have this in place.

    For your scenario, you want to use the so-called Post/Redirect/Get pattern. This pattern will make sure that the browser is redirected to a GET url, after doing a post. This will make sure that the user does not submit a form twice. It also makes sure that the browseris pointed to the new url.

    To do this in Struts2, you must use the Redirect Action Result. An example is also worked-out here.

    In your case this would be something like:

    ...
    <action name="Login" class="LoginAction">
    
        <result name="input">login.jsp</result>
        <result name="success" type="redirect">
            <param name="actionName">displaySalesOrder</param>
            <param name="namespace">/yournamespace</param>
        </result>            
        <result name="error">messages.jsp</result>
    
    </action>
    
    <action name="main" class="MainAction"> 
        <result name="success">main.jsp</result>
    </action>
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struts2 application with a single page that may show one of
I have one legacy web application based on struts2 (primarily using annotation). While debugging
I am using Struts application while running welcome page is run successfully after that
I am using struts2 for developing a web application. I have include the required
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I'm using Struts2, Spring, and Hibernate. I have written a simple Excel file called
I'm using Java+struts2+JSP as the web application framework. I have to pass some huge
I needed to create an application using Struts2 as MVC,Hibernate for data access and
I use tomcat. I am developing a web application using struts2, and I use
I am using struts2 to build a web application and I use struts2 tags

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.