Access session scope variables from a filter

I have a filter I am using to check if 2 people are loged in with the same user name.
When my web app loads I store the user name in a class that has session scope.
Is there a way for me to access this class from the Filter class?
How do I access the session instance from this class?
How do I pass parameters to the Filter class?
Thank you,

Similar Messages

  • Access of JSF Beans from Servlet Filter

    Is there any way how can I access session JSF beans from servlet filter?
    I need to check certain value of JSF bean stored in session scope in my filter.

    I am not sure about phase listener, this is the whole situation:
    as I am not using Container Managed Security with my JSF, after I do sucessfull login into application, I need to store some information into the session scope (user etc) and in the servlet filter I need to find out if the user is connected.
    I was trying to put such info into Servlet Session directly in my bean via External Context and reading the info in Filter.
    This is working fine when my application is running locally (jdev oc4j) but once deployed into Application server, when user login first time, user information is somehow removed from the session, and cannot figure out why.
    So I was thinking to try another approach, to find out from servlet filter if JSF bean value is set or not.
    Any other suggestions? Do not want to swicth to Container Manages Security now.

  • Accessing Session scope attributes in ADF BC

    Is there any groovy script for accessing session scope variables in ADF BC?

    Let me put forward my use case:
    My VO's in my application has a bind variable which is bound to currently logged in user (adf.context.securityContext.userName). Also my application has couple of AM's
    But now i'm adding complexity to my application where i'm implementing super user concept, a super user can login to the application, select a username (say 'user1'), and see the application as if 'user1' is logged in.
    So i'm trying to solve the problem by setting a session attribute for the user ('user1') and make it use in VO's
    Do you guys have any better solution to this problem?

  • Session scope variables and weird behaviour of AdfContext()

    what is the best method and correct API to create a session scope variable?
    I am currently using ADFContext().getCurrent().getSessionScope().get()/put(), but it looks like it has some problems: for some unkown reasons I loose the variable, that is get() returns null when called from a method of a (overridden)ViewRowImpl. Why does this happen?
    Thanks you in advance

    There are a couple of ways you can set values on a sessions scope but I would have to question if you really need a scope as high as session to accomplish what you want to do. At any rate, you should be able to store the value using the method you described but you could also try setting it using EL by using the setExpressionValue and resolveExpression methods in (you can find this in the latest fusion demo application). JSFUtils also has a getFromSession and storeOnSession that you could try.
    With all that said I don't think it is good practice to access scope variables from your model layer. You should write your method in the ViewRowImpl class to accept the value as a method parameter and then pass the value in through the binding layer or when invoking the method from your bean class.

  • Should we try to access session scope in ADF BC ?

    In the blog post "How to Access Session Scope in ADF BC "
    Andrejus Baranovskis suggests it is no problem to access session scope in ADF BC using
    Map sessionScope = ADFContext.getCurrent().getSessionScope();But I wonder if this is really a good practice, as it looks very much like breaking the MVC pattern.
    At the same time I wonder where the Oracle documentation says this would be a good or bad idea.
    One starting point could be the ADFContext.getCurrent() method
    that starts with saying "Gets the ADF context for the current thread. ..." which in a typical deployment scenario of ADF BC might not cause a problem.
    But, I wonder how defensive your programming should be when using the getSessionScope() method in your ADF Business Component code (that implements the Model).
    Ideas and feedback welcome.
    many thanks
    Jan Vervecken

    Hi Shay,
    Reviewing ADFContex methods it seems that this object shouldn't be accessible from BC. Example:
    public static ADFContext initADFContext(java.lang.Object context,
                                            java.lang.Object session,
                                            java.lang.Object request,
                                            java.lang.Object response)
        Initializes the ADFContext for the environment of the specified context.
            context - the ServletContext or PortletContext of the current execution environment.
            session - the HttpSession or PortletSession of the current execution environment. OPTIONAL.
            request - the HttpServletRequest or PortletRequest of the current execution environment. OPTIONAL.
            response - the HttpServletResponse or PortletResponse of the current execution environment. OPTIONAL.
            the ADFContext that was current when init was invoked. Should be passed back to resetADFContext after the block requiring the ADFContext has completed.Kuba

  • How do I access Captivate 6 variables from a playbar?

    I need to access Captivate 6 variables from a playbar. Does anybody know how? I know the parent/child relationship has changed from previous versions.

    Dear Herod,
    Thanks for the request, To program a FPGA target you must have the module
    Labview FPGA. So you cannot directly access the FPGA with LabWindows/CVI.
    But there is a way. Firstly create with Labview a Host VI that communicate with
    the FPGA target and compile this VI into a dll and then call it from CVI program.
    See the following link:
    Can I Use a Programming Language
    Other Than LabVIEW with a Reconfigurable I/O Board?
    LabWindows/CVI support for PXI 7831 R
    Best regards,

  • Session-scope variable for JSP page used in a frame

    I don't know if there's a way to do this at the same time:
    (1)- assign session scope to a variable (in order to be able to retrieve recurrently the previous value each time the JSP is called);
    (2)- set its visibility in a way that it could be accessed only by the page that defines it. The JSP is used in a frameset along with an other JSP that can potentially define identical session-scoped variable (You understand why I want to keep them separate)
    seems not to be the thing I need
    with SESSION_SCOPE, it behaves the same way as session.setAttribute(). with PAGE_SCOPE, condition (1) can't be satisfied.
    Does anybody have an idea ?
    Thanx in advance.

    I can see that you will not want to maintain two different files for every possible page on the site!
    It may be possible to do something like <frameset rows="*" cols="50%,*">
      <frame name="content1" src="file.jsp?frame=one" >
      <frame name="content2" src="file.jsp?frame=two" >
    </frameset>and then in the jsp<%
    String frame=request.getParameter("frame");
    %>This will set up two session attributes - "oneAttributeName" and "twoAttributeName". Depending on how many variables you have, this may prove just as difficult to maintain.
    You may end up having to simply pass url parameters between pages to maintain state within the individual frames, which is far from elegant also.
    I am interested in how you end up solving this one.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • How to access a javascript variable from Java?

    Here is my code:
    function validateLoginForm() {
        var username = document.getElementById('un');
        setCookie('un', username, 3650);
        HttpSession httpSession = request.getSession();
        httpSession.setMaxInactiveInterval(30 * 60); //30 minutes
        httpSession.setAttribute("un", username); //!prob here - cannot resolve 'username'
    }...but how do I access the javascript variable 'username' from the Java code?

    The only way to pass values between JavaScript and JSP is through cookies. It sucks, I know, but right now that is the only option.
    You already are creating a cookie in JavaScript. So go ahead and read it in Java:
    Cookie[] cookies = request.getCookies();
    for(int i = 0; i < cookies.length; i++) {
        Cookie c = cookies;
    if (c.getName().equals("un")) {
    // Do what you need here.

  • Accessing database package variables from Forms

    I have a database package that populates a table of values, i.e.
    type t_route_list is table of rt_route.RTR_ID%type;
    route_list t_route_list
    route_list gets populated by a package function and I want to access route_list in the Form.
    While I can access other package variables by writing a function that returns the variable, Forms doesnt seem to like functions that return a user defined datatype as above. I have also tried using a procedure with an OUT param instead of a function but it also fails with same error.
    v_route_list pkg_bulk_route_replace.t_route_list;
    This will not compile, but removing the index (1) from the last line makes it compile but crash with ORA-0600.
    The code above with message replaced with dbms_out.put_line works fine on TOAD.
    So my question is......
    Can my database package return a plsql table to a form and if so, how?!

    Actually I've got this to work now!
    Thde main culprit appears to be a difference in the version of sql or pl/sql used on forms (version 5) and the database (8.1.7).
    I had defined my table as a nested table. By redefining this as a indexed table, simply by adding on 'index by binary_integer' on my server package, I am suddenly able to access the elements of the table on my form. Fortunately this did not break the server code either - the table was populated using bulk collect and that still works.
    Still got a bit of coding to do, but things are looking up now.

  • Jsf session scope variables

    Hi All,
    How to set a variable which should be available throughout the session, I dont want to use session scoped managed beans for this.
    Using the following method is not working
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("variableName","value");is there any other way to set session scoped variables ?

    Got it working
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("variableName","value");This will make the variable session scoped
    Sai Krishna

  • Create variable from query filter

    I want to define  @prompt parameters as dimension or measure. So that we will use those parameters for the calculations we will use in our reports.
    For example; we will like to use prompt for year in efasion universe. This prompt is going to ask two year parameter (the operant we will use is between) We want to get the difference between these two years . and we will like to save that value as a  different variable.
    System: BusinessObjects XI 3.1
    Thanks in advance.
    Edited by: Akar Selcik on Apr 22, 2011 12:07 PM

    hi Dineshkumar89 ;
    I checked the your formula . But variable when used alone returns correct results But it returns wrong value or error  in same record.
    for instance;
    i created a variable named diff.year.  formula = Abs(ToNumber(First([Year]))-ToNumber(Last([Year])))
    selection value :  First : 2001  Last:  2003 
    year     Sales Revenue Diff.year
    2001     39600         0
    2001     3500         0
    2003     6500         0
    Results should be as below.
    year     Sales Revenue  Diff.year
    2001     39600          2
    2001     3500          2
    2003     6500           2

  • Problem accessing variables from java file to JSP page

    Hello Everyone,
    I have small problem accessing my method variables from my java bean file to a JSP page. can some please take a look and tell me why I can't populate my JSP page, I've been trying all day to get this done!!!
    This is my Java file
    package dev;
    import java.util.*;
    public class RoundDetail2
    public String string_gameID;
    public int string_card1;
    public String readDetail_topLayer;
    public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
    public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
    public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
    public RoundDetail2() throws FileNotFoundException
    DataInputStream inFile=
                 new DataInputStream(
                    new BufferedInputStream(
                   new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
    try { 
                 while((readDetail_topLayer = inFile.readLine()) != null)
              StringTokenizer tokenizer_topLayer = new StringTokenizer(readDetail_topLayer,"\t", true);
                   while  (tokenizer_topLayer.hasMoreTokens())
                        string_gameID = tokenizer_topLayer.nextToken();
         catch(IOException e)
         Thanks KT

    ......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
    Maybe you could post the relevant JSP code too?
    Hello again,
    Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
    Here is the JSP code
    <%@page import="dev.*" %>
    <%@page session="true" language="java" import="*" %>
    <jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
    <title>Round Detail</title>
      <table width="530" bordercolor="#000000" valign="top">
              <td align="left"  width="19%">Game ID<%=wagerhist.string_gameID%></td>
              <td align="left"  width="30%">  </td>
              <td align="left"  width="20%">card1</td>
              <td align="left"  width="31%">  </td>

  • Is there any way at all of accessing captivate variables from flash?

    I would be grateful for any help on this one.  I have been working in flash and I wanted to know whether there is any way at all of calling/accessing captivate 4 variables from flash (I'm working in flash Cs4 Actionscript 3.0 and I'm trialling Captivate 4, but I just want to know whether there is any way/method of communicating between a flash file and a captivate 4 file, and if so, can this be done with an embedded captivate 4 file/swf).  Surely there must be a way of communicating between the two - they are both Adobe products!
    Thanks for any help, pointers, advice, tips in advance.

    Hi Louon,
    Don't know if this would help you.
    We have many experts here who could give more precise answers.

  • Must command link parameter variable SESSION Scope??

    I add a EJB Session Bean Method to my page which returns an array:
    public Province[] getProvinces();
    When you place the Session Bean to the page, it automatically creates a REQUEST SCOPE VARIABLE called "provinceRemoteGetProvincesResultBean" in the type of Province array. And it automatically creates a Data Table to display the results.
    Up to this point every thing's cool!! I can call the method properly, get the results and display without any problem.
    However when I try to create a COMMAND LINK to one of the columns of the TABLE (e.g. Province has a NAME column) I have a problem:
    <h:commandLink styleClass="commandLink" id="lnkName" action="#{pc_ProvinceManagement.doLnkNameAction}">
    <h:outputText id="otxName" value="#{}" styleClass="outputText">
    <f:param name="provinceId" value="}"></f:param>
    The problem is that this "provinceRemoteGetProvincesResultBean" is REQUEST scope and Command Link does not work with REQUEST Scope variables!!!
    I had similar examples before, when I used the command link with a REQUEST SCOPE variable, it didn't work. When I use it with a SESSION Scope variable it works.
    In this particular case, I cannot make the Province[] a SESSION SCOPE variable, because it's not a class!!! Therefore I need to create a new class containing a Province[] and make that class a SESSION SCOPE variable, which makes things quite complicated!!

    Line 4: <f:param name="provinceId" value="}"></f:param>
    value="#varpro... >>> value="#{varpro...                                                                                                                                                                                                                                                                                       

Maybe you are looking for