Struts Plugin

Discussion in 'Java' started by RamRod, Jan 21, 2004.

  1. RamRod

    RamRod Guest

    I am new to JSP & Struts ...I am having some trouble with the -context-
    concept in Struts.

    I have a simple Struts PlugIn in which I have performed:

    context.setAttribute("SomeKey","value");

    Within the PlugIn I can print out the value associated with
    SomeKey as follows:

    System.err.println("---->In Plugin Value of SomeKey " +
    (String)context.getAttribute("SomeKey"));

    The problem is that I do NOT seem to be able to retrieve this key
    value in any of my JSP pages that are associated with this Struts
    project. To retrieve the key in my JSP's I am trying:

    <%
    String someValue = (String)session.getAttribute("someKey");
    %>
    Value : <%= someValue %>

    someValue is always returned as null ....anyone have any ideas?

    Thanks,

    Rod.
     
    RamRod, Jan 21, 2004
    #1
    1. Advertising

  2. RamRod

    Oscar Kind Guest

    RamRod <> wrote:
    > I am new to JSP & Struts ...I am having some trouble with the -context-
    > concept in Struts.
    >
    > I have a simple Struts PlugIn in which I have performed:
    >
    > context.setAttribute("SomeKey","value");


    [...]

    > The problem is that I do NOT seem to be able to retrieve this key
    > value in any of my JSP pages that are associated with this Struts
    > project. To retrieve the key in my JSP's I am trying:
    >
    > <%
    > String someValue = (String)session.getAttribute("someKey");
    > %>
    > Value : <%= someValue %>
    >
    > someValue is always returned as null ....anyone have any ideas?


    Retrieving it with
    String someValue = pageContext.getAttribute("someKey");
    works better, as the pageContext object searches the page, request,
    session and application scopes (in that order).

    I suggest you read up on the different contexts, and how to get/set values
    from them. Personally, I find the API for javax.servler.jsp.JspContext and
    javax.servler.jsp.PageContext to be quite helpful.


    Oscar

    --
    No trees were harmed in creating this message.
    However, a large number of electrons were terribly inconvenienced.
     
    Oscar Kind, Jan 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. koduru
    Replies:
    4
    Views:
    2,444
    koduru
    Jul 21, 2003
  2. PilotYid
    Replies:
    1
    Views:
    634
    Andrew Thompson
    Oct 31, 2005
  3. Marcin Cenkier
    Replies:
    1
    Views:
    5,434
    Marcin Cenkier
    Apr 12, 2006
  4. Jimmy
    Replies:
    0
    Views:
    516
    Jimmy
    Mar 15, 2007
  5. Replies:
    1
    Views:
    735
Loading...

Share This Page