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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:07:57+00:00 2026-06-17T22:07:57+00:00

Say I have a profile page, which has an ‘edit your profile’ link. The

  • 0

Say I have a profile page, which has an ‘edit your profile’ link. The profile page can be viewed by all the users, but the edit link button should be visible only for a logged in user viewing his profile, not another user’s profile.

As of now I have this code,

<sec:authorize access="isAuthenticated()">
<sec:authentication property="principal.username" var="principal"/>
<c:if test="${profile_username eq principal}">   <!--profile_username is the username of the viewed profile  -->
<!-- edit your profile link -->
</c:if>
</sec:authorize>    

Is there a cleaner way a doing this?? May be a one liner like

<sec:authorize access="isTheSamePerson()"/>.

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-17T22:07:58+00:00Added an answer on June 17, 2026 at 10:07 pm

    You want to take into account actual domain object. There is special ACL feature in Spring Security for these purposes. You can set up it and use corresponding accesscontrollist tag:

    <sec:accesscontrollist hasPermission="2" domainObject="${profile}">
        <!-- Your edit link goes here -->
        <!-- "2" means write permission -->
        <!-- Be sure that you use Spring Security >= 3.1.2. This syntax may not works for smaller versions due to bugs  -->
    </sec:accesscontrollist>
    

    It may be an overkill if you have only one situation like this.

    Option number 2. You can define a custom web security expression:

    <sec:authorize access="isOwner(#profile)"/>.
    

    It is not so simple too.

    I think a custom JSP tag (tag file) will be the most simple solution:

    <customtags:authorizeeditaccount account="${profile}"/> 
    

    This tag will do the same things. It will look much better.

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

Sidebar

Related Questions

Let's say you have a profile page that can only be accessed by the
ok. lets say I have a secure url pattern /secure/link-profile optionally, there can be
Say if I have a controller, profile, which has just two actions. The first
I have an and users can login and view their own profile with a
Basically in order to have a profile Block u need - let's say profile
How would I display dynamic content, say profile pages with the url syntax mysite.com/users/user1
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
Let's say I have this given namespace or url like this http://localhost:8090/MyApp/pageowner/profile?id=1 where in
I have user/micropost/comment models where users can comment on others' microposts. Under every post
I am writing ruby on rails application, which will have 2 different users types

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.