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. Advertisements

  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. Advertisements

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. Katie Wright
    Replies:
    8
    Views:
    4,738
    Andrea Desole
    Jan 7, 2005
  2. koduru
    Replies:
    4
    Views:
    2,542
    koduru
    Jul 21, 2003
  3. Jason Us
    Replies:
    0
    Views:
    1,163
    Jason Us
    Oct 4, 2003
  4. PilotYid
    Replies:
    1
    Views:
    939
    Andrew Thompson
    Oct 31, 2005
  5. crack_cs

    using Easy Struts plugin

    crack_cs, Mar 21, 2006, in forum: Java
    Replies:
    5
    Views:
    872
    crack_cs
    Mar 21, 2006
  6. Marcin Cenkier
    Replies:
    1
    Views:
    5,842
    Marcin Cenkier
    Apr 12, 2006
  7. Jimmy
    Replies:
    0
    Views:
    755
    Jimmy
    Mar 15, 2007
  8. Replies:
    1
    Views:
    963
Loading...