Code to set and destroy session variables in Java Server Pages(JSP)

code to set and destroy session variables in Java Server Pages(JSP)
we have use following statement to set session variable
session.setAttribute("userClient",id);
we have use following statement to destroy session variable
session.setAttribute("userClient","");
and
the session.invalidate() is not working
Plz. solve this probem

code to set and destroy session variables in Java
Server Pages(JSP)
we have use following statement to set session
variable
session.setAttribute("userClient",id);
we have use following statement to destroy session
variable
session.setAttribute("userClient","");Perhaps if you tried using
session.setAttribute("userClient", null);
or
session.removeAttribute("userClient");
and
the session.invalidate() is not workingNot working how?
>
Plz. solve this probem

Similar Messages

  • How do I set a breakpoint in a Java Server page (.jsp)?

    I have set up an application for remote debugging and am able to connect to it from JDeveloper. When the code execution comes to breakpoints that I have set in java (.java) files they work and the application stops so I can debug etc.
    This also applies to breakpoints set in java code that is called from Java Server pages.
    However if I set breakpoints directly in a java server page whether it is in html code or in java code (such as scriplets) the execution does not stop and the breakpoints are ignored.
    Why? Is there some extra thing I have to do? I have tried in Project Properties/Run/Debug/Profile/Edit/Launch Settings to choose server as Virtual Machine for instance but that does not change anything.
    Comment. I do not know if this is of interest but I am going to add some java server pages to an application and they are defined in a directory like this:
    . . . src\org\yawlfoundation\yawl\resourcing\jsf\jsp
    but when the tomcat deploys the .war file they end up here:
    . . . apache-tomcat-6.0.18\webapps\resourceService
    As I can find no package declaration in a .jsp file this should not matter but I mention it anyway.
    Edited by: user10477024 on Nov 25, 2008 5:32 AM

    Hi user10477024,
    thanks for explaining your background on what you are trying to do and I do understand the approach you are taking. Unlike user10689900's completely random post.
    I've tried to convey why there is no support for JSP debugging in JDev, but again the main reason is that the current frameworks do not code Java directly into a JSP. The JSP is purely used to position the components on the page aiding visual design and real Java classes in tag libs do the rest.
    So the evolution has been:
    Servlets (Java classes writing HTML logic and intermingling presentation and business logic)
    JSP 1.0 JSP (HTML looking) files where you can add scriptlets enclosed in <% ... %> <- you are here
    JSP 1.1 Introduction of Tags and Tag libraries, tag libraries are true java classes and the JSP controls layout and simpler more elegant design.
    Really JSP 1.1 is all about building reusable components together in tag libraries that can be reused across pages and improving design by not mixing presentation and business logic code together.
    If I had inherited something as you have, my advice (if you can) would be to code up some tag libraries because it would be a good learning experience and would be very helpful for moving to more advanced frameworks like JSF.
    regards,
    Brenden

  • How to set and read a variable in a UIX page

    In a similar fashion to how JSP works, I need to set a variable if a certain condition occurs at a specific processing point in my UIX page, and then conditionally create output in the page based on the value in my variable. How can this be done in UIX?
    Brad

    Hi ,
    Decalring the Varible :
    <?xdoxslt:set_variable($_XDOCTX, 'var', 0)?>
    Do the calculation :
    <?xdoxslt:set_variable($_XDOCTX,'var', xdoxslt:get_variable($_XDOCTX,'var‘)+ XML columnname)?>
    Display the Variable :
    <?xdoxslt:get_variable($_XDOCTX, 'var')?>
    Declare the varaible before your loop starts.Do the calculation part inside the loop so for each row it will be updated.
    Display the results where you want using the form field and place the display varaible syntax.
    Hope this will helpful for you.
    Thanks,
    Ananth

  • Access session variable in Java Function in JSP

    Hi Experts !!
    I am developing an application using STRUTS MVC...
    Very sorry if u have problem understanding my question, i ll try to improve... and sorry if i can't post codes here
    Basic question is ....
    I want to open a word document on pageLoad of JSP, the word document is not a single document, there is a form in which there is a "name" and "template" whenever user clicks on a button there is one action attached to it which creates a copy of that template in a different folder.. on the next page OnLoad i want to open that particular document. for that i have created a variable and also have set in the session, just want to access it in the below code.
    I have a formbean in which i have a variable, the scope is session, that variable i have put it in session also. but i want to access that variable in a "java function" in JSP so that "onLoad" page that function should work.
    JSP---
    <script type="text/javascript">
    function openDocument() {
    var w = new ActiveXObject("Word.Application");
    var docText;
    var obj;
    var a;
    if (w != null) {
    w.Visible = true;
    obj = w.Documents.Open(I HAVE TO ACCESS THAT VARIABLE HERE);
    </script>
    FORMBEAN----
    public class CreateSOWFormBean extends ActionForm {
    private String workflowName;
    private String comment;
    private String sowTemplate;
    private String sowFileCreated;
    public String getSowFileCreated() {
    return sowFileCreated;
    public void setSowFileCreated(String sowFileCreated) {
    this.sowFileCreated = sowFileCreated;
    sowFileCreated is the variable that i have accessed in session and that value i have to pass in that function in JSP....
    I am aware of something like
    obj = w.Documents.Open(<%'sowFileCreated'%>);
    but i m not sure how to write....
    Plz help.....

    If you're working under a framework like struts you should definitely be using JSTL tags rather than scriptlet code to access variables within the page. With JSTL code <% codes can be almost entirely avoided.
    To transfer a value from a Servlet to a JSP don't use a session variable, use a request attribute. Session variables should only be used when values have to survive from one transaction to another.
    You can write something like:
    obj = w.Documents.open('<c:out value="${openURL}"/>');in the Javascript portion of your JSP.
    Just beware of potential problems with quotes. The coresponding code in the Servlet would be like:
    request.setAttribute("openURL", openUrl);

  • Setting and retrieving session using pl/sql

    How to set and retrieve session using pl/sql?Can anyone help me?

    mrs wrote:
    create or replace
    function get_login_details(in_user in VARCHAR2,in_pwd in VARCHAR2,in_cname in VARCHAR2)
    ..snipped..The code should look as follows:
    create or replace function AuthenticateUser( userName varchar2, userPassw varchar2, userGroup varchar2 )
    return integer is
      i integer;
    begin
      --// purpose of the SQL is simply to check if such a row exist -
    --// no data from the row needs to be fetched
      select 1 into i from acl_users_gv
      where user_name = userName
      and password = userPassw
      and entity_group_name = userGroup;
      --// if the SQL succeeded, then the row exists and matches
      --// the authentication details
      return( 0 );
    exception when NO_DATA_FOUND then
      --// SQL failed to find a row - authentication details do
      --// not exist
      return( 1 );
    end;No need to fetch data unnecessarily. No need too check the fetched data when the column values are already checked via the SQL filter condition (predicate).
    No need to return a flag variable as a freely formatted text string containing Successful Login and login failed. That is not a robust design to use a string variable like that. Use boolean for true/false. Or use integer values 0/1.
    This is my function get_login_details.And I need to get this 'o_mesg' in other java file also.Standard PL/SQL call from Java. The SQL string to execute contains an anonymous PL/SQL and needs to use bind variables. E.g.
    begin
      :result := AuthenticateUse( :userName, :userPassw, :userGroup );
    end;
    Can you suggest the right way, how I can get this variable in other pages?That depends on whether there is database session state. If there is, authentication can be done once only via a trusted context, that specifies whether the session is authenticated.
    If this is done from an app server that uses a db session pool and stateless db sessions, the state needs to be kept in the app server.
    Do you understand what stateful versus stateless db sessions are, and what the differences are?

  • Using HttpHeader to set value for session variables

    Hi,
    We want to set values for 2 session variables (USER and ROLEID) using HttpHeader in obiee 11g. Has anyone tried this? How can we achieve this?
    I found the below note on the forum for setting value for the USER session variable. how can we set the ROLEID session variable also? is it possible to set values for 2 variables?
    for setting the USER session variable,
    You should add this in $BI_HOME/bifoundation/web/display/authenticationschemas.xml:
    <SchemaKeyVariable source="httpHeader" nameInSource="Proxy-Remote-User" forceValue="SSO"/>
    <AuthenticationSchema name="SSO" displayName="Single Sign On" userID="IMPERSONATE" proxyUserID="NQ_SESSION.RUNAS" options="noLogoffUI noLogonUI">
    <RequestVariable source="httpHeader" type="auth" nameInSource="Proxy-Remote-User" biVariableName="IMPERSONATE" options="required"/>
    </AuthenticationSchema>
    Please suggest.
    Thanks.

    I think maybe your SnmpValue type or value is not corrent.
    1.3.6.1.4.1.7064.201.1.200.100.0 is Enum control type
    when I use
    SnmpValue val = new SnmpString("0");
    It doesn't work, but when I use
    SnmpValue val = new SnmpInt(0);
    It works. I think the JDMK should give some warning message when the type is not correct. :)
    The code is following:
    final SnmpVarBindList setList = new SnmpVarBindList(" set varbind list ");
    SnmpOid oid = new SnmpOid("1.3.6.1.4.1.7064.201.1.200.100.0");
    SnmpValue val = new SnmpInt(0);
    SnmpVarBind valueBind = new SnmpVarBind(oid, val);
    setList.addVarBind( valueBind );
    SnmpRequest setRequest = session.snmpSetRequest(null, setList);

  • Unable to fetch session variables in my application page code behind

    hi,
    my env:  1  WFE  server which hosts the  central admin and my web appln,  1 sql server box  
    i am having a custom web part[ listviewbyquery web part]  which populates the site collection/ sub site's document library contents . also it reads some query string values and pushes these  values into  session variables.
    and i am having another application page in this application which reads this session variables and  perform some operation in a custom sql db. But i am unable to read these session variables on page load of this  application page.
    am unable to debug also. so, would like to know is there any way i can see, what values  are getting passed to this page and verify the session variables are accessed correctly.
    or
    is this  by design, that its not possible to read session variables in the application page ?
    if i am not having a visual studio env. to debug, how to test these  session variable  existence / to find the root cause of this issue.
    note: already configured session state in IIS , http  modules section. am using Page.Session["myvariable1"].tostring() to fetch the  session variables.
    help is appreciated!

    i have found out myself. i have put  page.response.write(mysessionvariables) in the code and deployed and tested in my env. and i was able to find out the reason and i have fixed it with proper validation check.

  • Set up a Session Variable

    Hi,
    How to setup a session variable of User id in PHP in
    Dreamweaver Style. Is it possible to assign the session variable
    value equal to user id from the recordset......if yes i need the
    procedure. Thanks in advance.

    prashi123 wrote:
    > How to setup a session variable of User id in PHP in
    Dreamweaver Style. Is it
    > possible to assign the session variable value equal to
    user id from the
    > recordset......if yes i need the procedure.
    There is no "Dreamweaver style" for setting up a session
    variable. You
    do it in exactly the same way as for any PHP page. Put this
    at the
    beginning of the page:
    session_start();
    Retrieve the value that you want from the recordset and
    assign it to a
    session variable like this:
    $_SESSION['user_id'] = $row_recordsetName['user_id'];
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • How to set a new session variable?

    Hi all,
    Can anybody say how to set a new session variable in istore?

    Hi,
    you can use either
    pageContext.getAttribute(VAR, PageContext.REQUEST_SCOPE);
    or
    <%@page session="true" %>
    session.putValue
    session.getValue
    Hope this will help.
    Thanks
    Gurjeet

  • If user disable cookie how to set and use session with URL Rewritting

    if user disable cookie how to set and use session with URL Rewritting by append session ID in url

    If cookies are disabled, then app server will automatically try to use URL rewriting for session control. Programmer's responsibility is to encode any links or redirects using
    response.encodeURL("/yourPage.jsp")
    and
    response.encodeRedirectURL("/yourPage.jsp")
    See API for details
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html#encodeURL(java.lang.String))

  • Declare, Set, and Use a variable in a SQL Developer Query

    I come from the SQL Server world and am trying to do something very simple: Declare, set, and use a variable in a query. For example:
    Declare @lastPeriod date;
    Set @lastPeriod = (select max(payperiod) from table 1 where payperiod < current_date);
    Select field 1,
    Field2
    From table2
    Where payperiod = @lastPeriod
    The variable is going to be used in more areas in the query which is why I am simply not using a Sub-query in the where clause. I appreciate any assistance.

    This forum is for issues with the SQL Developer tool. You'd get more response in the SQL And PL/SQL forum.
    That said, read up on bind variables and substitution variables.
    Whenever you can you should use Bind variables (e.g. *:lastPeriod* ), as they increase performance. In sqldev, there's no need to declare as you will be prompted to enter them on execution (F9), but you do if you execute as script (F5) (e.g. VARIABLE lastPeriod VARCHAR2(30);).
    Alternatively, Substitution variables (e.g. *&lastPeriod* ) will literally be substituted in your statement before the database parses it. In sqldev, there's no need to declare as you will be prompted to enter them on execution (either F9 or F5), but you can (DEF lastPeriod='TEST'; ).
    Have fun,
    K.

  • Integration of PL/SQL and JSP (Java Server Pages)

    I need to match a web application developed with PL/SQL with another developed in JSP (Java Server Pages) the problem is that the two apps interact with the same databese, an share de same users, I need to know how to get the user and password loged into pl/sql when the user want to use same of de .jsp pages running on another application server?

    Hi Michael Vstling,
    Did you try the java classes library (SDOAPI) that can be downloaded from OTN?
    It may provide you with a better alternative when manipulating geometries in the Java space. There is an adapter in SDOAPI which can convert a JDBC STRUCT object into Java Geometry object defined in SDOAPI, and vice versa.
    There are at least two ways in mixing PL/SQL and Java. The first one, as you mentioned, is to define your custom function in terms of PL/SQL and call it from within your Java program. With SDOAPI, you have the second option, which is to define your own functions in Java using SDOAPI and deploy them as Java stored procedures in db. You can then call them from within your PL/SQL code. In either way performance depends on a lot of things and generally it requires a "try and improve" approach.
    About JPublisher and sdo_ordinate_array it may not be a spatial related problem. Did you try search the Java-related forums first?
    LJ

  • Clearing Session and/or App variables with Log-out Page?

    Greetings
    I have 3 distinct user types for my app- admins, appraisers and clients.
    All have their own directories and each directory has it's own Application.cfm:
    1) <cfapplication name="appraiseri"
    applicationtimeout="#CreateTimeSpan(0,2,0,0)#"
    clientmanagement="Yes"
    sessionmanagement="Yes"
    sessiontimeout="#CreateTimeSpan(0,2,0,0)#"
    SetClientCookies="Yes">
    2) <cfapplication name="appraiserview" ......
    3) <cfapplication name="clientview" .......
    Each have their own login which simply uses their ID in the DB as the session variable.
    login_do.cfm:
    1) Appraisers: <CFIF auth_direct_appraiser.RecordCount NEQ 0 >
    <cfset Session.appraiser_user_id =auth_direct_appraiser.appraiser_ID>
    <cfset Session.appraiser_fname =auth_direct_appraiser.appraiser_fname>
    <cfset Session.appraiser_lname =auth_direct_appraiser.appraiser_lname>
    2) Admins: <cfset Session.user_id =auth_direct.staff_ID> ......
    3) Clients: <cfset Session.processor_user_id =auth_direct_processor.processor_ID>
    I have had a session persisting for a week now- I have no idea how to get rid of it, and if one simply hits the "login" submit button with no UN or PW, it runs a query on a client (the same one) ?
    My logout page is not working at all- if the code were correct, it would clear any session variable? I have not really set an app variable (except timeout) so no need to clear that?
    Here is the code:
    <CFLOCK SCOPE="Session" TYPE="Exclusive" TIMEOUT="60">
        <CFLOOP COLLECTION="#Session#" ITEM="Key">
            <CFIF NOT ListFindNoCase('IveSeenIT', Key)>
                <CFSET StructDelete(Session, Key)>
            </CFIF>
        </CFLOOP>
    </CFLOCK>
    <SCRIPT LANGUAGE="JavaScript">
        alert("You have been logged out from the XXXXX Intranet")
        location.href='login.cfm';
    </SCRIPT>
    Any help would be appreciated- this is leaving a huge security gap in the app right now.
    Thanks

    It in unnecessary to delete session keys to invalidate them. With proper coding they should be invalidated once the session times out.
    Sessiontimeout values are usually around half an hour and applicationtimeout values are usually of the order of 1 day. Also, one way to relate session to login is to use the loginStorage attribute. If you have no need for client management, switch it off.
    Hence, for example,
    <cfapplication name="appraiseri"
    applicationtimeout="#CreateTimeSpan(1,0,0,0)#"
    clientmanagement="no"
    sessionmanagement="Yes"
    sessiontimeout="#CreateTimeSpan(0,0,30,0)#"
    SetClientCookies="Yes"
    loginStorage="session">
    I am assuming that, for login and logout pages, you will - ignoring the details - have something like
    Login:
    <cflogin>
            <cfloginuser name = "some_name" password = "some_password"   roles = "appraiser"/>
    </cflogin>
    Logout:
    <cflogout>

  • Spry XML data set and dynamic post variables

    Hi,
    I am trying to create an XML data set that has dynamic post
    variables.
    Everytime something is pressed on the page a variable changes
    and I then want to reload the XML data set using the new variable.
    I know I can just pull in an XML with all possible variables
    and filter client side but this would make it way too large.
    Does anyone know what I may need to do.
    I tried this:
    var myVar = 0;
    var dss = new Spry.Data.XMLDataSet (
    '../../cgi-bin/server_details.pl' , 'top' , { method: 'POST' ,
    postData: sid=ajaja21&ip=127.0.0.1&cid=' . myVar ,
    subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
    "true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
    "descending", useCache: false, loadInterval: 10000 } );
    onclick="myVar=1";
    But the script doesn't understand the post variables sent (it
    does when I remove the . myVar part and put in a static value). I
    think it isn't sending that dynamic variable with the post
    variables.
    Any ideas anyone?
    Thanks

    Well I had it working when I stripped back everything and
    just had the dss data set and a single onclick function, but now
    that I put it back together it hash foobared again.
    Here are the relevant bits of code that I've changed.
    The function to change server id:
    //function to run when changing the server id
    function changeServer ( sid ) {
    //set the url to use the current server id
    dss.setURL = ( '../../cgi-bin/server_details.pl' , { method:
    'POST' , postData:
    'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid='+sid
    //force a reload of the server data
    dss.loadData();
    The inital load of the data set
    var dss = new Spry.Data.XMLDataSet (
    '../../cgi-bin/server_details.pl' , 'yams' , { method: 'POST' ,
    postData:
    'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid=0' ,
    subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
    "true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
    "descending", useCache: false, loadInterval: 10000 } );
    And the part that changes the server id
    <td align="left" style="cursor:default; width:174px;"
    onclick="changeServer({dsv::servers/server/@id})">{dsv::servers/server/name}</td>
    I checked that the function is receiving the correct server
    id and I even tried hard coding the cid variable to 2 in the change
    function but it still wasn't changing on the server side.
    Any ideas?
    Thanks

  • JSR 168 Portlet and PORTLET_SCOPE session variables

    Hi,
    I have a JSR-168 portlet that is putting session variables on the PortletSession. I have some variables that use "PORTLET_SCOPE" for that particular portlet. This works fine if I add the portlet directly on a page, no problems. Its able to retrieve and put variables on the PortletSession with PORTLET_SCOPE and retrieve them properly.
    The problem comes when when I have my JSR-168 portlet on a page, then select "Publish Page as Portlet", and then add that page (that contains the JSR-168 Portlet) to another page. Now, when I try to retrieve a variable that was put on the PortletSession w/ PORTLET_SCOPE, it returns null. So its like variables put on the PortletSession with PORTLET_SCOPE doesn't work properly if you add it as a page onto another page.
    In case that wasn't clear, let's say I have Page1 which contains my JSR-168 portlet and I selected "Publish Page as a Portlet."
    If I go to Page1, it works fine, no problems at all.
    Now, I have Page 2. I add Page 1 to Page 2. NOW, the Portlet on Page 1 doesn't work properly and I've narrowed it down to a problem with the PortletSession when PORTLET_SCOPE is used. Has anyone else run into this problem? I'm guessing the problem is the fact that page is published as a portlet and PORTLET_SCOPE doesn't work properly. Is this a bug or expected behavior?? If so, is there a workaround?
    Thanks in advance.

    Frank,
    The taglib is not in the classpath of the Portal server. We access other methods of the ftl taglib, like <f:webResources relativePath='js/myScripts.js' />at places higher up in the JSP and it has no problems with those ftl taglib calls.
    If I understand correctly, since the Portal is hosting a remote portlet, the Portal is only getting html from the remote portlet producer, not the actual JSP to compile into a web page. If that is true, the Portal never sees the taglib code, just the html that is produced from it - so it would not need the taglib in its classpath.
    There is something special about the "invoke" method of the taglib where it makes a call back to the Enterprise server. I think when it tries to go back to the Enterprise server, the Portal server has a problem with it.
    Thanks.
    Edited by marshallbenfield at 08/15/2007 6:02 AM
    Edited by marshallbenfield at 08/15/2007 6:03 AM

Maybe you are looking for