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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:43:53+00:00 2026-05-11T18:43:53+00:00

I have a JSP struts application that uses Spring to integrate with the services/dao/database.

  • 0

I have a JSP struts application that uses Spring to integrate with the services/dao/database. Basically, struts uses spring to get the data from the DB, it builds the form and forward them to the JSP files.

I have a header file that is injected in each JSP file using Tiles. I would like to show “Welcome John Doe” on each page inside the header. Where “John Doe” is the name of the currently logged user.

What would be the best approach to do that? The solution that I can think of is:

  1. Use a Spring Filter the catch the http request. Load the user from the database using a cookie that contains the user id(*) and put the name in a session bean named “CurrentUser”

  2. In “header.jsp”, get the spring application context. Using it, load the bean “CurrentUser” and get the name. Put the name in the html.

I think I could get this to work. But I’m not certain this is the best way to do it. Any thought on my approach?


(*) Of course, the cookie will be encrypted

  • 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-05-11T18:43:53+00:00Added an answer on May 11, 2026 at 6:43 pm

    Although it may be an extremely large hammer for your fairly simple use-case, we have gotten a really neat spring-jsp integration (jsp 2.1 required!) by using ELResolver. By following this tutorial you can basically inject any spring managed bean into your el-context and allow it to be accessed using jsp-el like this:

    ${spring.mybean.myproperty}

    You can choose to inject pre-defined beans into your el-context or simply pass “mybean” to getBean and allow almost anything spring-managed to be accessible from jsp. mybean could easily be a session-scoped spring bean.

    I’m not totally sure how this would align with tiles, though.

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

Sidebar

Related Questions

I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle
I have a JSP that is using Spring:form tags to bind controls to a
I have jsp/struts application need to upgrade. Currently we only have 1 websystem(branch) and
We have a Struts 2 web application that's used by pretty much every employee
I am changing a GET to a POST. Currently I have .jsp?id=a,b,c,d. When changing
I have a JSP which attaches a XSL to an XML document pulled from
Right now I have a JSP page that allows to sort some items, when
I'm running tomcat and have some jsp pages that display a subset of a
I have Maven modules that produce a Flex application as an SWF file. I
I am working on a basic Struts based application that is experience major spikes

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.