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 8181963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:42:00+00:00 2026-06-07T00:42:00+00:00

I am using spring mvc in my application,when i created user i have to

  • 0

I am using spring mvc in my application,when i created user i have to show the success message in a header,
so i used this code

modelAndView.setViewName("redirect:/mainPage");
        modelAndView.addObject("successMessage", "user created successfully");

        return modelAndView;

But my problem is i am getting this message in browser url. suppose if i use like as below,Success message is showing in a header of mainpage ,but the records in main page disappear.

modelAndView.setViewName("mainPage");
            modelAndView.addObject("successMessage", "user created successfully");

            return modelAndView;

this is my mainpage.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<jsp:include page="../templates/header.jsp"></jsp:include>

<script type="text/javascript" src="js/bootstrap-dropdown.js"></script>
<script type="text/javascript">
// Implement checkbox-like buttons
$(".toggle-buttons > .g-button").click(function() {
    $(this).siblings(".g-button").removeClass("checked");
    $(this).addClass("checked");
});
</script>

<style>
.errorblock {
    color: #060505;
    background-color: #ffEEEE;
    border: 3px solid #ff0000;
    padding: 8px;
    margin: 16px;
}
.successblock {
    color: #060505;
    background-color: #9EF2DF;
    border: 3px solid #06B98F;
    padding: 8px;
    margin: 16px;
}
</style>
<c:if test="${not empty errorMessage}">
    <div class="errorblock">${errorMessage}</div>
</c:if>

<c:if test="${not empty successMessage}">
    <div class="successblock" >${successMessage}</div>
</c:if>

<!-- full width -->
<div class="widget" >
    <div class="header"><span><img src="images/icon/color_18/audio_knob.png"  alt="dashboard"/>Mobee Robot</span>
    </div>
    <div class="content" >

        <div id="UITab">
            <ul class="tabs" >

                <li><a href="#tab1">Mobee User(s)</a></li>




            </ul>
            <div class="tab_container" >

                <sec:authorize access="hasRole('ROLE_USER')">
                <div id="tab1" class="tab_content">
                    <div class="load_page">
                        <form>
                            <div class="tableName inTab">
                                <h3><img src="images/icon/color_18/user.png"  alt="users"/>Mobee Users</h3>
                                <table id="userData" class="display data_table2">
                                    <thead>
                                        <tr>
                                           <th><div class="th_wrapp">Id</div></th>
                                            <th><div class="th_wrapp">User Name</div></th>
                                            <th><div class="th_wrapp">Email Id</div></th>
                                            <th><div class="th_wrapp">Created By</div></th>
                                            <th><div class="th_wrapp">Created On</div></th>
                                            <th><div class="th_wrapp">Status</div></th>
                                            <th><div class="th_wrapp">Manage</div></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <c:forEach items="${mobeeUsers}" var="mobeeRobotUser">
                                            <tr class="odd gradeX">
                                                <td>${mobeeRobotUser.id}</td>
                                                <td><a href="<%=request.getContextPath() %>/useredit?id=${mobeeRobotUser.id}">${mobeeRobotUser.userName}</a> </td>
                                                <td>${mobeeRobotUser.emailId}</td>
                                                <td>${mobeeRobotUser.createdBy}</td>
                                                <td><fmt:formatDate value="${mobeeRobotUser.createdOn}" pattern="dd-MMM-yyyy"/></td>
                                                <td>${mobeeRobotUser.status}</td>

                                                <td>
                                                    <span class="tip">
                                                        <a id="1" href="<%=request.getContextPath() %>/userdelete?id=${mobeeRobotUser.id}" class="Delete" name="${mobeeRobotUser.userName}" title="Delete">
                                                            <img src="images/icon/color_18/close.png"/>
                                                        </a>

                                                    </span>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </form>
                    </div>
                </div><!-- End tab1 -->
                </sec:authorize>
</div><!-- End tab Container -->
        </div><!-- End UITab -->
        <!-- clear fix -->
        <div class="clear"></div>
    </div><!-- End Content -->
</div><!-- End full width -->

<jsp:include page="../templates/footer.jsp"></jsp:include>

please help me

thanks in advance

  • 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-07T00:42:02+00:00Added an answer on June 7, 2026 at 12:42 am

    Once you do a redirect the value is not preserved. So you are not getting successMessage in the mainPage controller.

    See here a similar question.

    You can put the value in session as suggested.
    Or in the next controller fetch it from the request and then set it to the modelandview.

    Best of luck.

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

Sidebar

Related Questions

I have a spring MVC application using JSP as my view technologies with Jquery
I am using Spring MVC to build my web application, and I have a
I have a spring mvc application and I am rendering some pdfs using classes
Am new to programming. I have created a Spring MVC web application. It has
I have a spring mvc application that I am using Hibernate with. I am
I'm using Spring's form tag library in a Spring MVC application that I am
In my Spring MVC application I am using DTO in the presentation layer in
I'm using itext to generate pdf in my spring mvc application. The pdf is
I'm using Spring MVC and jquery autocomplete, my spring controller looks like this @RequestMapping(value
I'm using spring MVC, and I have a custom authentication/security system that I had

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.