Are session variables available at custom tags ?

Are the variables that I put into the session available at cutom tag classes ?
Thanks
Eli

Hi elibarnett,
1. yes, you get it via the javax.servlet.jsp.PageContext class.
2. For example:
     public int doStartTag()
          javax.servlet.http.HttpSession session = pageContext.getSession();
-- Paul.

Similar Messages

  • How to access variables passed in custom tag body

    I am developing custom tags in my application. I need to pass some variables from the .jsp file into tag file. I want these to be passed as body of the tag rather than as tag parameter. It seems the correct syntax for this is:
    <myTags:display> someVariable </myTags:display>
    Question 1: Can I not use this as: <myTags:display someVariable /> Since this tag will be used at many places in the jsp, I dont want to write myTags:display twice for every usage.
    Question 2:
    I want to call the tags from main.jsp like:
    <% String var1 = "Display Me Please"; %>
    <myTags:display var1 />I want the tag file to do some processing on the value stored in var1. I've written the following code in tag file, display.tag:
    <jsp:doBody var="theBody" />
    <% Object obj = (Object) request.getAttribute ("theBody"); %>This code snippet gives me access to obj which has the value "var1". Now how do I access the value that is contained in "var1".
    Edited by: coolkomal on Jun 3, 2009 7:45 AM

    coolkomal wrote:
    I am developing custom tags in my application. I need to pass some variables from the .jsp file into tag file. I want these to be passed as body of the tag rather than as tag parameter. It seems the correct syntax for this is:
    <myTags:display> someVariable </myTags:display>
    Question 1: Can I not use this as: <myTags:display someVariable /> Since this tag will be used at many places in the jsp, I dont want to write myTags:display twice for every usage.
    <myTags:display var="<%=someVariable>"/> is a valid syntax for performing respective action of that variable. You can also use EL to pass the variable ${someVariable} provided the custom tag provide support for EL.
    >
    Question 2:
    I want to call the tags from main.jsp like:
    <% String var1 = "Display Me Please"; %>
    <myTags:display var1 />
    Just ensure that you declare all the related variables in Main.jsp and statically include Main.jsp in your jsp such that you do the checking
    [http://java.sun.com/products/jsp/tags/11/syntaxref117.html]
    >
    I want the tag file to do some processing on the value stored in var1. I've written the following code in tag file, display.tag:
    <jsp:doBody var="theBody" />
    <% Object obj = (Object) request.getAttribute ("theBody"); %>This code snippet gives me access to obj which has the value "var1". Now how do I access the value that is contained in "var1".Can be done provided you code it the right way. Start learning basics of how to create custom taglibraries to gain more knowledge on how things can be managed.
    [http://java.sun.com/javaee/5/docs/tutorial/doc/bnalj.html]

  • What are the variables available on 0CALDAY

    HI EXPERTS,
    I want to know the list of variables on a 0calday.How can i know?
    Can i get this information for all the standard characteristics / time chars.?
    Beacause ,when i open my query designer ,i see only few variables under the characteristic 0calday.
    For example,
    when user enters a date, i need to show him both entered date   and entire months in next column.
    so i need to find.Is there any SAP variable available already for this purpose?
    I aslo have some columns.........etc,,
    Can any one help. me..
    Regards
    Laxman

    Hi Experts,
    I want to extend my doubt a little more.
    I have a requirment  as below.
    User will enter a range of Date say 01.06.2011 to 25.06.2011.
    I need to show him data in two columns one cloumn for the entered day range and second column for prevoius month date rangei.e(01.05.2011 to 25.05.2011)
    can i achive this without  using Customer Exit.
    Regards
    Laxman

  • How to use a variable of jsp custom tag in my java code?

    hi folks,
    i got a folderList tag like this:
    ArrayList list = new ArrayList(20);
    %>
    <foo:folderList path="${attributes.newsPath}" var="year" contentType="folder">
    <%
              list.add(${year.contentEntryName});   // of course, this doesn't work
    %>
    </foo:folderList>I think, its clear what I want to do. I am just wondering how I can use my Variable "year" in the Java code between <% %>...

    <% list.add(year.getContentEntryName()); %>
    You have to have defined in the custom tag that "var" relates to a scripting variable that you want defined.
    <tag>
      <variable>
        <name-given>var</name-given>
        <variable-class>myPackage.myClass</variable-class>
        <declare>true</declare>
        <scope>NESTED</scope>
      </variable>
    </tag> Cheers,
    evnafets

  • Scripting variables and custom tags

    Hello,
    I wonder how I could use a scripting variable in a custom tag? I have written a tag that formats number and dates, and would like to be able to do somethin like
    <% double x = 12,345; %>
    <x:write name="x" format="xyz" />
    Also I wonder how best to implement tags with parameters? I don't suppose it's possible to nest tags or scriplets in a way like <x:bla name="test" value="<%= 12345 %>" />? It seems tedious having to create an Object just to pass a Parameter.
    Many thanks in advance for any help!
    Bjoern

    I think I found the solution,
    pageContext.setAttribute(...,...)

  • Are Pre-defined roles available for Customizing Synchronization?

    Hello Guys,
    In the SAP Help for Solution Manager: <<http://help.sap.com/saphelp_sm40/helpdata/en/48/647e3ddf01910fe10000000a114084/content.htm>>
    it's mentioned that certain authorizations needs to be given for the involved people (admin & customizer), in both the SOLMAN & the component systems.
    Also, its said that the role Application Consultant has all authorizations which are needed to set-up the Customizing Distribution in the SAP Solution Manager system & the authorization profile S_CUS_CMP can be used in the component systems.
    But the AC role "SAP_SOL_AC_COMP" & "S_CUS_CMP" profile donot have all the necessary authorizations specified.
    E.g: Role SAP_SOL_AC_COMP doesnot have project creation authority, whereas S_CUS_CMP has only some authorizations.
    So my question is:
    Along with these two, are there any other roles/profiles which complete the gaps & are readily available for usage ?
    Last option would be to manually create & include the mentioned auth. objects.
    Thanks & Regards
    Chaitu

    Hello Chait,
    Regarding your two questions:
    1) There are seperate roles available for customizing purposes, please check note 803142 <i>Roles for satellite systems</i>. The note administration list an xls with the respective roles for customizing distribution and comparison, namely
    SAP_BC_CUS_ADMIN
    SAP_BC_CUS_CUSTOMIZER
    S_CUS_CMP
    2) What I can recommend is the quick reference for setting up Customizing Distribution which is also part of the help documentation
    http://help.sap.com/saphelp_sm40/helpdata/en/c4/533d4050d89523e10000000a1550b0/content.htm
    Regards,
    Doreen

  • What is session variables in BSP

    Hi
    I am using using IC Webclient. can anyone help me to findout the details about session varibales ?
    Best Regards
    Bhavishya

    hi,
    Session variables is a handy way to define a persistent variable.The standard variables used in ColdFusion can be only transferred or sent to the next page before it is necessary to restate the variable. In some situations, you may want to define a variable that will apply to all the pages during a single session of the user. An example is when the pages a user sees are personalized to his or her specific needs. In such a case, session variables are defined and used.
    Session variable persistent
    A session variable is one of several types of variables that persist across multiple templates:
    >Server variables - Accessible by all clients and applications on a single
    >Application variables - Tied to a single application and accessible by multiple clients
    >Client variables - Tied to a single client over multiple sessions
    >Session variables - Exist for one client or browser during a single session
    >Cookie variables
    Session variables are designed to hold information that you seldom write but are read often.
    Defining session variables
    Session variables are normally defined in the Application template, but can be also defined on all applicable pages.
    Application template
    The standard method of using session variables is to define them in the application.cfm template, which is a special ColdFusion page that is processed before the other pages in a session. It usually should be in the session root directory.
    CFAPPLICATION tag
    To enable the use of session variables, as well as client and application management, you should use the CFAPPLICATION tag in the Application template. A typical tag would be:
    <CFAPPLICATION NAME="Name"
    SESSIONMANAGEMENT="Yes"
    SESSIONTIMEOUT="#CreateTimeSpan(0, 0, 20, 0)#">
    where:
    >NAME is required to avoid problems if you have session variables tied to separate applications.
    >SESSIONMANAGEMENT is required to enable the session variables.
    >SESSIONTIMEOUT is optional and limits the time the variables will stay in memory (20 minutes in the example) Note that the default is 20 minutes, so you really may not need this unless you want to change that number.
    Setting variables
    After the CFAPPLICATION tag, you can set your session variables, using the CFSET tag. You must always refer to session variables with the prefix session. Thus, you could define a session variable, such as:
    <CFSET session.name="#form.othername#">
    Should lock variables
    You should lock the session variables to avoid problems when several people are using the system at the same time. An example of this is:
    <CFLOCK TIMEOUT="30" NAME="#session.sessionID#" TYPE="Exclusive">
    <CFSET session.name="#form.othername#">
    </CFLOCK>
    Defined on applicable pages
    A problem in using the Application.cfm template is that it is often difficult to change your session variables, once they have been set. An alternative is to use the CFAPPLICATION tag in each applicable page:
    <CFAPPLICATION NAME="Name"
    SESSIONMANAGEMENT="Yes">
    You then can define the session variable in the first page, accessed:
    <CFOUTPUT QUERY="return">
    <CFSET session.ID="#ID#">
    </CFOUTPUT>
    This is a compromise between the standard method and defining the variable on each page.
    Example of use
    Suppose a user logged in to the site. His name could be sent through a form and entered in Application.cfm. Then the session will constantly refer to him by name.
    Application.cfm
    <CFAPPLICATION NAME="Name"
    SESSIONMANAGEMENT="Yes">
    <CFSET session.name="#form.othername#">
    Start.cfm
    <CFOUTPUT>
    <H1>Hello #session.name#</H1>
    </CFOUTPUT>

  • JSP in custom tag attributes...

    Sirs,
              A very nice feature from a development perspective, would be the ability
              to use JSP code within custom tags. Say I have a page on which I wish
              to give all the information on a widget. Say further that I have
              implemented a tag that writes out all the info of a widget as HTML
              table. I would like to write something like this:
              <mytaglib:widgetTag widgetID="<%=request.getParameter("widget_id")%>"
              />
              As far as I know, in the current implementation of custom taglibs this
              does not seem to be possible. Instead you end up writing something like
              this:
              <mytaglib:widgetTag>
              <mytaglib:getWidget><%=request.getParameter("widget_id")%>"</mytaglib:getWidget>
              <mytaglib:displayWidget />
              </mytaglib:widgetTag>
              Which is much more like a scripting language than a heirarchical XML .
              Now, I could always just use the request object within the tag helper
              classes, but this gives up flexibility and can introduce security
              issues, and it also makes the tags much more difficult to work with...
              In short, we should push for JSP evaluation of tag attributes. Weblogic
              could leap ahead of other app servers in this area (making up for the
              custom tag performance issues, to be solve in sp6) and Sun would, once
              again, follow Weblogic's lead and rewrite the standard to include this
              functionality.
              Regards,
              Carson Gross
              

    Carson,
              Perhaps the problem is that you are treating custom tags like one would
              construct an imperative language. I have never had to put Java or use beans
              or %= or even parameters to tags into a JSP because of custom tags.
              The real problem is writing/packaging/maintaining all those tags; sure could
              use a tool that did just that ;-)
              Peace,
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Carson Gross" <[email protected]> wrote in message
              news:[email protected]...
              > Sirs,
              >
              > A very nice feature from a development perspective, would be the ability
              > to use JSP code within custom tags. Say I have a page on which I wish
              > to give all the information on a widget. Say further that I have
              > implemented a tag that writes out all the info of a widget as HTML
              > table. I would like to write something like this:
              >
              > <mytaglib:widgetTag widgetID="<%=request.getParameter("widget_id")%>"
              > />
              >
              > As far as I know, in the current implementation of custom taglibs this
              > does not seem to be possible. Instead you end up writing something like
              > this:
              >
              > <mytaglib:widgetTag>
              >
              >
              <mytaglib:getWidget><%=request.getParameter("widget_id")%>"</mytaglib:getWid
              get>
              >
              > <mytaglib:displayWidget />
              > </mytaglib:widgetTag>
              >
              > Which is much more like a scripting language than a heirarchical XML .
              > Now, I could always just use the request object within the tag helper
              > classes, but this gives up flexibility and can introduce security
              > issues, and it also makes the tags much more difficult to work with...
              >
              > In short, we should push for JSP evaluation of tag attributes. Weblogic
              > could leap ahead of other app servers in this area (making up for the
              > custom tag performance issues, to be solve in sp6) and Sun would, once
              > again, follow Weblogic's lead and rewrite the standard to include this
              > functionality.
              >
              > Regards,
              > Carson Gross
              >
              

  • Nested Custom Tags

    Hello,
    I have a custom tag that I've written that has some
    attributes. I want to nest that tag inside of itself, and access
    the attibutes of the parent tag. However, when I try to access the
    parent tag's data from the child all I get is the child tag's data!
    If there are two of the same custom tags in the context stack, is
    it possible to access one from the other? Thanks for your help.
    Tim

    > I can't use the
    > CALLER scope, as that references the page that called
    the first custom tag, no
    > matter how deeply nested I am.
    I think you should test the advice, before you make
    assertions like this.
    The CALLER scope refers to the variables scope of the
    template that called
    the currently executing custom tag. If your calling stack is
    like this:
    index.cfm
    customTagA.cfm
    customTagB.cfm
    Then the situation is this:
    1) In index.cfm: no caller scope.
    2) In customTagA.cfm: caller scope references index.cfm's
    variables scope.
    3) custoTagB.cfm: caller scope references customTagA.cfm's
    variables scope
    (NOT index.cfm's one).
    Similarly, if your calling stack is like this:
    index.cfm
    customTag.cfm (*)
    customTag.cfm
    customTag.cfm
    customTag.cfm
    Then the caller scope in each customTag.cfm instance refers
    to the
    variables scope of the file above it. The only caller scope
    that
    references index.cfm's variables scope is the customTag
    instance marked
    with (*).
    If I understand your requirement, this is what you want. This
    is why I
    suggested it.
    Adam

  • Difference b/w a custom tag and cfinclude

    Hi,
    can anyone pls describe the difference between a cold fusion
    custom tag and cfinclude. Or how they are processed in the server?
    While we use the custom tag it nearly functions same as
    cfinclude....i can't think of any ...

    ajithmanmu wrote:
    > Hi,
    > can anyone pls describe the difference between a cold
    fusion custom tag and
    > cfinclude. Or how they are processed in the server?
    While we use the custom tag
    > it nearly functions same as cfinclude....i can't think
    of any ...
    >
    <cfinclude...> does just that. It logically includes
    the code in the
    current template to be parsed at that point and time. With
    <cfinclude...> the code exists in the same scope is the
    entire template
    sharing all variables.
    A custom tag is a separate template with it's own local
    variables as
    well as start and end states that can be used to create much
    more
    sophisticated interactions. One thing that a custom tag can
    do that an
    include can not do is reiteration, where a tag can
    dynamically call itself.

  • Assigning bean property to custom tag's attribute

    1. The #{beanName.property} notation can only be used inside JSF tags.
    2. The attributes of custom tags does not accept embedded tags.
    e.g. <prefix:tagName attrib1="<jsftag>">
    I need to assign a bean's property to the attrib1 attribute. how do I do this?

    Alternatively, how can I assign the value of a bean property to a variable?
    e.g.
    <%
    int var=<bean.property>
    %>
    I can use the variable on the custom tag like this:
    <prefix:tagName attrib1="<%=var%>"> OR
    But this may not be the best solution though because I have to use scriptlets...

  • Accessing custom tag value in scripting code

    Hi All,
    How can i access my custom tag value in scripting code?
    For example, assuming my tag is <myTag:display value="myValue"/>, how can i System.out this value in scripting code? I wanna do <% System.out.prinln(xxx); %> where xxx should be my custom tag value.
    Thanks in advance,
    Leo.

    I understand that you want to store "myValue" somewhere accesible by scripting. The more easy and portable way is to store that value in an attribute, for instance:
    <myTag:display value="myValue" var="myVar" scope="session"/>And in the custom tag code:
    // translate scope string to PageContext scope values
    pageContext.setAttribute(var, value, scope);This ensures compatibility with Java Standard TagLibrary and EL:
    <c:out value="${myVar}"/>And finally, scripting:
    <% Object value = pageContext.findAttribute(var); %>

  • Access to variable in custom tag

    I have a custom tag called sendmail and I use it like this:
    <cc:sendmail smtpServer="..." to="..." ....>
    </cc:sendmail>
    While the SendMailTag are processing the tag, it sets a boolean variable based on if the mail was sent or not. My tag extends BodyTagSupport, and everything works like it is supposed to. What I want to do now, is to allow the developer using the tag to have access to the boolean in the tag representing the status of the mail, inside the body of the tag, so he can do "this" if the mail was sent and "that" if it failed. Something like this:
    <cc:sendmail smtpServer="..." to=".." ..>
    if(status) {
    // tell the user that the message was sent
    else {
    // present an error message
    </cc:sendmail>
    Yeah, I can use the bodyContent object to output the variable value, but I want to give the jsp developer the possibility to do whatever he like, based on that boolean value.
    Anyone know how I can do this?

    Well, your sendmail tag could add the boolean value to the session scope. For example inside your sendmail tag code after you send the mail message, do this..boolean ok = sendMailRoutine();
    pageContext.setAttribute("isSent",ok,PageContext.SESSION_SCOPE);then in your jsp page after you call the send mail tag, you can get the boolean value by typing...boolean ok = (boolean)session.getAttribute("isSent");Alternativley, you can create another function in your sendmail tag library to get the isSent boolean value. Say for example you had<cc:isSent messageId="">  or whateverthen the tag code would beboolean ok = pageContext.getAttribute("isSent",PageContext.SESSION_SCOPE);This tag could then send a message back to the browser if the boolean value is false.pageContext.getOut().println("Failed to send message.");Now if your not confused... you don;t have to hard code the value "isSent". You can pass that in through your tag just like you did with the smtpServer and to IDs.
    Hope this helps.
    -S-

  • Session variable not storing in custom trigger

    I have a custom trigger in which I want to store a session variable , so i can use the value in the insert transaction which happens after. But for some reason the session variable is not stored, resulting in the data not being stored.
    any clues would help.
    rudi
    here are the relevant code:
    //start Trigger_Custom_Subject_Mentor trigger
    function Trigger_Custom_Subject_Mentor(&$tNG) {
    //Check subject exists
    @session_start();
    $_SESSION['sb_id'] = $subject_id;
    //end Trigger_Custom_Subject_Mentor trigger
    // Make an insert transaction instance
    $ins_share = new tNG_insert($conn_smart);
    $tNGs->addTransaction($ins_share);
    // Register triggers
    $ins_share->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
    $ins_share->registerTrigger("END", "Trigger_Redirect", 90);
    // Add columns
    $ins_share->setTable("`share`");
    $ins_share->addColumn("share_item", "NUMERIC_TYPE", "POST", "share_item");
    $ins_share->addColumn("share_subject", "NUMERIC_TYPE", "SESSION", "sb_id");
    $ins_share->setPrimaryKey("share_id", "NUMERIC_TYPE");
    // Register triggers
    $ins_share->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
    $ins_share->registerTrigger("BEFORE", "Trigger_Custom_Subject_Mentor", 50);
    $ins_share->registerTrigger("END", "Trigger_Default_Redirect", 99, "share.php?item_id={share_item}");

    hi User,
    1) Pull a dummy column in Fx use the Session variable --->(Variable -->session )
    2) Next, goto narrative view in Narrative view section use @1
    3) If u want you can hide the column that we created in criteria section

  • Clearing custom session variable in 5.0

    I have set a custom session variable in a method called in the OnAfterLogin PEI.
    Do I need to ckear this session variable on logout? If so, how do I do that?
    Or does the session variable clear on its own if teh session is abandoned or killed on logout?
    I just want to make sure I am not leaking any memory and do proper housekeeping.
    Thanks!
    Vanita
    Staples

    Sam,
    It appears that you are one of the few installations that actually used a display/formatting page under 4.x. Under 5.0 you have the option of going directly to the source of the card or gatewaying the card. Those are your only two options to my knowledge. I suppose that the answer might rest on using docfetch but this would require a custom CWS.
    Good Luck
    Phil Orion

Maybe you are looking for

  • Cannot find Fiori Backend Role

    Dear expert, I'm implementing Fiori wave 2 Leave Request Approval and Purchase Order Approval for customer. The customer is using ERP EHP6, thus we installed GBAPP002 and GBHCM003 on the backend. Both the components are at the latest patch. However c

  • Problem with subform set

    Hi all , I am facing a problem with subform set. When i use two subform sets with same set of conditions in a form, only the first subform set works while the second one does nothing. Did any of you faced the same problem ? If so Please let me know t

  • Xorg.conf - Multi Monitor Issue

    I have read that using nvidia-settings to configure X does not work very well. After trying it myself and being unable to get it to work proprly, I've tried my hand at writing my xorg.conf from scratch using the info on the wiki. I'm having issues an

  • I want to discontinue printing the daily manager

    I want to discontinue the automatic  printing  ofthe daily manager

  • Any one who has read chap15 of Thinking in JAVA,2nd Ed. please take a look.

    I'm testing the RMI example in chap15.When I run the PerfectTime class I always get an error message(xuke is my computer's name,and I've already conncetted to the ISP and started the registry server and produced the stub&skeleton classes as the book