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

  • Home
  • SEARCH
  • 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 8289483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:31:03+00:00 2026-06-08T12:31:03+00:00

I am using Struts2 for my project. Working on simple registration project. When user

  • 0

I am using Struts2 for my project.
Working on simple registration project. When user Login , he is directed to his profile, but on hitting browser’s back button login page appears again.
XML:

<action name="home" class="bharat.Home">
            <result name="success">/jsp/home.jsp</result>
             <result name="student">/jsp/Welcome.jsp</result>
</action>
<action name="Login" class="bharat.LoginAction">
            <result name="input">/index.jsp</result>
            <result name="success">/jsp/Welcome.jsp</result>
</action>

Home.java:

public String execute() {
           if((String)ActionContext.getContext().getSession().get("studentName")!=null)
        {
            return "student";
        }
        if((String) ActionContext.getContext().getSession().get("instructorName")!=null)
        {
            return "instructor";
        }
        session = ActionContext.getContext().getSession();
        session.put("roleName","notAdmin");
        return SUCCESS;
    }

Home.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="cache-control" content="no-cache" />
<meta name="expires" content="0" />
<meta name="pragma" content="no-cache" />
    <sx:head/>

I want that when user hit back button after being logged in , he must be redirected back to same page. Can anyone Help me please..

  • 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-08T12:31:04+00:00Added an answer on June 8, 2026 at 12:31 pm

    You can use post and redirect method where all you need to when user login he/she should be redirected to welcome page.
    If you see banking sites or any other secure site they have deployed the same mechanism and it work perfectly fine.

    Secondly i suggest not to play with ActionContext as Struts2 has given you a more clean and flexible way to implement SessionAware interface, by implementing this your Action is free from underlying framework dependencies and easy to test

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple web project app. I am using struts2 and
I'm using MyEclipse to develop a really simple Java Struts project. Everything was working
i am working on a struts2 web application-project and using netbeans 6.9. i want
Hi i am using struts2 and hibernate in my project. When i am trying
Hi i am using struts2 and hibernate in my project. I need to use
I'm trying to start a new struts 2 project using maven (struts2 blank archetype)
I am developing project using Spring , Struts2 & Hibernate . Now I want
Hi I'm using Eclipse on a EJB3 project, struts2 and hibernate.Server is JBoss 7.1.
I am working on a project which uses Java,MySql,Struts2 MVC and Hibernate. I tried
I am working in a struts project and there I am using Solr Server

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.