#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19

    substitution variable(?)


    Not quite sure how to phrase this. We're trying to figure out how to pass what would be a global variable as opposed to a session variable. I work with SAS a lot, so if someone is familiar with SAS macrovariables, perhaps they can offer the correct translation. We tried a $, but that doesn't quite do what we need (in SAS, you assign a value to a macrovar, either hardcoded or dynamically -- we are trying to do the latter). I know I've done this before, but for the life of me, I can't remember how and I can't remember what to look for, so I've been going a bit nuts this weekend. Help? Thanks very much.


    Example:

    String text = "newText";

    String <%= text %> = "True Description";

    I would like to dynamically create a String called newText and place "True Description" as its value.

    Kind regards,
    Pat Flickner
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    I'm not sure what you're trying to do. You can define variables that are outside of the main method the jsp compiles into by using <%! ... %>. So:
    <%!
    String text = "newText";
    %>
    Then later you'd have:
    <%
    text = "True Description";
    %>

    Be careful if you do this though, as most application servers will try to process concurrent requests to your jsp as separate threads, and reassigning the value in multiple threads will lead to problems.

    You can do something like:
    <%
    String text = "newText";
    text = "True Description";
    %>
    The value is: <%=text%><br>
    <%
    text = "New description";
    %>
    The value is: <%=text%><br>

    Like I said, I'm not sure what you're trying to do. And I've never used SAS
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    What I'm attempting to do is address an java servlet object by a different name. It was suggested that we use a hash table, but this seems an awful roundabout way to get something simple done. I would have thought that we could pass the value to the servlet, but it doesn't accept it -- drops the last portion of what we want.

    We're calling an object, mdvi. We want to address it as mdvi_prod and mdvi_dev so that we can display the results side by side from the same starting browser (we have a main browser that submit links to child browsers, so this is causing us some issues and we think it's the reason we can't easily just pass the value we want to see).

    Sorry -- sometimes extracting information from me can be like pulling molars. Twisted molars. Embedded. Sideways.
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Umm... still confused.
    It sounds to me like you're trying to have a browser open two child windows, both displaying information from the same object (mdvi), but calling the object by different names (mdvi_prod and mdvi_dev, respectively). Is that right?
    How are you passing the values to the servlet? And what exactly are you trying to pass?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    Confusion understandable. We have nothing to do with the parent-child relationship going on here. If I had my way, our Web Police would take their mitts off the thing, but that ain't gonna happen. So, I'm stuck.

    Basically, what you are saying is correct: The parent can call as many child browsers as it chooses. The problem arises in our set of links; apparently, we're the only ones who know how to actually use jsp to code dynamically; the other team hard-codes everything, so they don't have an issue. But it takes five minutes to implement an application using our jsp's as opposed to their five weeks, minimum, and that's only once you've completed the back end.

    Anyway, because of its truly dynamic nature, the jsp's rely upon data tables to feed it information. This works for passing info to the jsp and to the objects, but it doesn't work with loading an object, inherit the original object. (I think I said that right.) Hence, the quandry.

    Doex that shed any more light?
    Programmer at large
  10. #6
  11. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Ok, so you're wanting to pass an object from one browser window to another, is that right?
    Well, then you've got choices.
    request, session, and application.
    I *think* the request object can store objects, but I'm not sure on that. You'll probably want one of the other two. I'd recommend session, unless you're only wanting one object available to every user of the system.
    In your main window you'd have something like:
    mdvi my_obj = new mdvi();
    String obj_name = "mdvi";
    session.setAttribute( obj_name, my_obj );
    And your link would be:
    somepage.jsp?obj_name=<%=obj_name%>
    Then the child page:
    mdvi new_obj = session.getAttribute( request.getParameter( "obj_name" ) );

    Is that what you had in mind?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Phoenix AZ
    Posts
    30
    Rep Power
    19
    We'll try it. It looks like it just might work. Thanks! I'll let you know what happens.

    Pat
    Programmer at large

IMN logo majestic logo threadwatch logo seochat tools logo