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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:15:01+00:00 2026-06-12T00:15:01+00:00

I am new and testing struts2. Got value in session declared in the interceptor.

  • 0

I am new and testing struts2. Got value in session declared in the interceptor. Want to display session value in JSP but unable to do it.

Anyone tell me how to do it in OGNL?

Interceptor

package com.myapp.interceptors;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class GreetingInterceptor implements Interceptor {


    @Override
    public void destroy() {
    }

    @Override
    public void init() {
    }

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        String Greeting = "My first Interceptor.";
        invocation.getInvocationContext().getSession().put("Greeting", Greeting);

        String result = invocation.invoke();
        return result;
    }
}

struts.xml

<struts>

    <!-- Configuration for the default package. -->
    <package name="default" namespace="/" extends="struts-default">
        <interceptors>
            <interceptor name="Greeting" class="com.myapp.interceptors.GreetingInterceptor"/>
        </interceptors>

        <!-- Greeting  -->
        <action name="greet" method="Greet" class="com.myapp.actions.GreetingAction">
            <result name="success">index.jsp</result>
            <interceptor-ref name="Greeting"/>
        </action>
    </package>

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

    you can access in your jsp as <s:property value='#session.Greeting'/>

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

Sidebar

Related Questions

I'm NOT new to testing, but got really confused with the mess of recommendations
I'm new with unit testing in visual studio and I want to load a
I'm really new to testing so go easy on me. I've got Seleneium working
I'm new to testing and know there are similar questions, but I can't find
I'm new on testing Django applications but I feel there should be some sort
I'm testing new PhpStorm5 in Ubuntu 12.04. Synchronization via sftp works OK, but it
I am new to testing and selenium and got lots of doubts, one such
I am fairly new to testing and have a UsersController that I want to
I'm pretty new to testing and mocking and i am trying to write a
I am new to testing.I have to test some C# classes.Kindly let me know

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.