PageContext object in a Tag class

Hello,
I am learning how to code custom Jsp tags.
I noticed that to get an attribute from the session (or page, request, application) object I can call the findAttribute method of the pageContext object.
Until now, I would call getSession() method of the HttpServletRequest object in order to get the session object and then get whichever attribute I needed.
Why can't I do that here? Is there no way to get an HttpServletRequest object in a JSP?
Is the pageContext object implicit in all JSP pages?
I'm just trying to understand the topic better.
Thank you
_

Objects in request scope are accessible by all the components which are part of same request processing. These objects are saved as attribute-value pairs by an implementing instance of HttpServletRequest interface. request is available as implicit object in the jsp page. You can add an attribute to the request object in one jsp page and then can forward the control to a different jsp page from the calling page. In this case, same request object will be available in the new jsp page as well.

Similar Messages

  • Custom taglib access the variable of jsp in the tag class

    Hi guys:
    I have a question about taglib.the scenario below
    there are a set of tag,they all need to access a variable that declare in the jsp.yes ,I can use the approach like this,
    first I declare a variable
    <%!String variable="test";%>
    then pass the value
    <myTag:hello att="<%=variable%>"/>,but I think that's stupid,because all tags access the same variable.why not get the variable in tag class?
    for example
    public int doStartTag() {
    String variable=;//get the variable at here
    I mean,I want to get the variable's value in my tag class directly without passing parameter in the jsp via attribute of tag ?
    can I do like this?if yes,how can I?
    thanks advance!

    Hi,
    Review pageContext, TagSupport from the JSP and Tag Extensions API. You can put the variable into any of the four scopes and retrieve it using the pageContext object.

  • Custom component/tag class:  ---which setters/getters do what?

    Hi
    I'm trying to create a custom component, but, there is a major concept that I do not understand...
    ---What are the setters/getters in the "component" class used for?...
    ---What are the setters/getters in the "tag" class used for?
    Another way of asking is...
    ---Which setters/getters are used simply to keep track of attribute name/id/key?
    ---Which setters and getters refer to the actual objects that the attribute names point to?
    The reason for my confusion is that nearly all "custom component" examples I've seen thus far, utilize attributes that point to "String" objects... (i.e., as opposed to ArrayList, HashMap, etc)...
    This makes it difficult for me to distinguish whether the String values in the getters/setters are referring to the String name/"id" of the attribute...or, the String "value" of the attribute...
    I have not been able to verify how I should code the getter/setters (and type casts) for other kinds of objects like ArrayLists, HashMaps, etc
    For example, a typical logic mechanism Ive seen in the custom "tag" examples is as follows...
    in a "tag" class...
            if( tabledata != null )
                if (isValueReference (tabledata))
                    FacesContext context = FacesContext.getCurrentInstance ();
                    Application app = context.getApplication ();
                    ValueBinding vb = app.createValueBinding (tabledata);
                    component.setValueBinding ("tabledata", vb);
                else
                    component.getAttributes ().put ("tabledata", tabledata);
    in the "component" class...
        public void setTabledata (List tabledata)
            this.tabledata = tabledata;
        public List getTabledata ()
            if(null != tabledata)
                return tabledata;
            ValueBinding _vb = getValueBinding ("tabledata");
            if(_vb != null)
                return (List)_vb.getValue (getFacesContext ());
            else
                return null;
        }...considering the above code,
    ---when/where should the "tabledata" variable be referring the "name/id" of the attribute?...
    ---when/where should the "tabledata" variable be referring to the "value" of the attribute?...
    ...as, I need to change the type casting to adjust to what it should be...
    ***NOTE: This is one error that I'm getting, and I believe it is because I do not understand how getter/setter is used in "component" and "tag" classe, i.e., :
    "org.apache.jasper.JasperException: jsp.error.beans.property.conversion
         org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)"...
    Thanks for any help on this!
    sd

    The "tabledata" variable always refers the local value of the attribute.
    When using a value binding to some backing bean,
    the local value is null and the model value is owned by the bean.
    You don't need any casting in the tag class nor the component class.
    The setters/getters in the component class specify the type of the attributes.
    Conversion from/to String to/from the type is done automatically if possible.
    When the automatic conversion is impossible, you should specify f:converter
    for the attribute.

  • Exception in Tag Classes

              Hi,
              I am trying to use custom tag libraries with WebLogic. Whenever I use some custom tag in some JSP page, an exception occurs in the tag class code. Following is a portion of stack trace.
              Thu Sep 21 12:58:04 GMT+08:00 2000:<E> <WebAppServletContext-ebanking> Root cause of ServletException
              javax.servlet.ServletException: runtime failure in custom tag 'text'
                   at jsp_servlet._webpages._login._jspService(_login.java,
              Compiled Code)
                   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
                   at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet
              (ServletStubImpl.java:124)
              For some tags the exception is ClassCastException.
              Is there any special configuration reqired for using tag libraries? Please help.
              Thanks
              Amir
              

    You need to look at the class cast issues that have been discussed in the
              weblogic servlet newsgroup. Chances are that you are storing a value in the
              session or request object and getting it back out in the custom tag, right?
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Amir" <[email protected]> wrote in message
              news:39c9b0df$[email protected]..
              >
              > Hi,
              >
              > I am trying to use custom tag libraries with WebLogic. Whenever I use some
              custom tag in some JSP page, an exception occurs in the tag class code.
              Following is a portion of stack trace.
              >
              > Thu Sep 21 12:58:04 GMT+08:00 2000:<E> <WebAppServletContext-ebanking>
              Root cause of ServletException
              > javax.servlet.ServletException: runtime failure in custom tag 'text'
              > at jsp_servlet._webpages._login._jspService(_login.java,
              > Compiled Code)
              > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > at
              > weblogic.servlet.internal.ServletStubImpl.invokeServlet
              > (ServletStubImpl.java:124)
              >
              >
              > For some tags the exception is ClassCastException.
              >
              > Is there any special configuration reqired for using tag libraries? Please
              help.
              >
              > Thanks
              > Amir
              >
              

  • How to resolve #{row} of af:table in custom tag class?

    Hi all,
    My customer creates custom converter tag with some attributes. When they use it outside af:table, it works as expected.
    However when they use it in af:table and set "#{row.value}" into the tag's attribute, it doesn't work because it can't resolve #{row} EL expression.
    The method they wrote is like below.
    private Object getExpressionValue(ValueExpression expression) {
    if (expression == null) {
    return null;
    final ELContext elContext =
    FacesContext.getCurrentInstance().getELContext();
    return expression.getValue(elContext);
    Does anyone know the way to do resolve #{row} expresison in custom tag class?
    If you share sample codes, it will be much appreciated.
    Regards,
    Atsushi

    Hi,
    the row variable is a temporary variables, which means that #{row} may work when the table renders but not when users edit fields in a table and then submit the change. You don't really mention what doesn't work for your customer (and wouldn't it be better your customer could post here on OTN to avoid you becoming a dispatcher?) . An expression #{row.value} for example doesn't exist unless your customer uses a POJO model that has a property "value" in which case the entity has a setValue/getValue.
    Frank

  • Choosing JRE used by Plug-in in OBJECT OR EMBED tags

    I have successfully used the type attribute of the EMBED tag to choose the Plug-in version with fire fox and used the clsid of the OBJECT tag to choose the Plug-in version used by IE to run an applet.
    Is there a way in the OBJECT or EMBED tags to force the selected plug-in to use a specific JRE that is known to be installed?

    http://www.mozilla.org/docs/web-developer/upgrade_2.html
    some text from this site:
    APPLET
    The APPLET element has been deprecated in HTML 4.01 in favor of OBJECT.
    <p>
    <applet code="HelloWorldApplet.class" height="200" width="350"></applet>
    </p>can be converted to:
    <p>
    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase=
    "http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0"
    codetype="application/java" standby="Loading of applet in progress..."
    height="200" width="350">
    <param name="code" value="HelloWorldApplet.class">
    <!--[if !IE]>
    Mozilla 1.x, Firefox 1.x, Netscape 7.x and others will use the inner
    object, the nested object
    -->
         <object classid="java:HelloWorldApplet.class"
         standby="Loading of applet in progress..."
         height="200" width="350">
         <p>Your browser does not seem to have java support enabled
         or it does not have a Java Plug-in.<br>
         <a href="http://www.java.com/en/download/manual.jsp">You can download
         the latest Java Plug-in here. (free download; 15MB)</a></p>
         </object>
    <!--<![endif]-->
    </object>
    </p>The above code will work for MSIE 6, Mozilla-based browsers and other standards-based browsers; also, it will validate in either HTML 4.01 transitional or HTML 4.01 strict.
    Explanations on the code:
    According to HTML 4.01 recommendation, when an <object> is not rendered (because its content type is unsupported or because it does not support ActiveX controls), then the browser should render its contents instead: here, it is another <object>, an alternate <object>. Here, the inner <object> will be rendered by browsers not supporting java plug-in triggered by an ActiveX.
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93":
    this clsid value will make the MSIE 6 browser use the highest possible version (installed on the user's machine) of JRE. Sometimes, MSIE 6 users have several JRE plug-in versions installed.
    codebase=
    "http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0":
    the codebase defines the minimum version for the JRE; here it is 1.4.2. In case the browser does not have a java plug-in or if its version is earlier than 1.4.2, then an automatic download of the latest 1.4.2 version will start. This may be a debatable choice: on one hand, the latest available JRE plug-in has several security patches and bug fixes, on the other hand, forcing a 15MB download without a prior explicit consent of the user can not be best.

  • Passing an object into a tag

    Hello
    I have a tag file called foo.tag
    <%@tag description="some tag" pageEncoding="UTF-8"%>
    <%@tag import="java.util.*"%>
    <%@attribute name="list" type="java.util.List" required="true"%>
    <h4>I am a list</h4>
    <p>Class: <%=list.getClass()%></p>And in my index.jsp I do:
    <%@ taglib prefix="jc" tagdir="/WEB-INF/tags" %>
    <%
          List bar = new ArrayList();
          bar.add("test");
    %>
    <jc:foo list="<%=bar%>"/>..in order to pass the reference of bar in my tag. That works, but I know that it's "bad" practice to have <%= %> inside your JSPs. How could I improve the parameter passing? If I say <jc:foo list="bar"/> then I only get a "bar" String on the tag file.
    thanks

    Thanks for your reply.
    But is there a better way of doing this? Yeah, there is a slightly better way if you are using JSP 2.0 (properly configured). Then you can do:
    <% List bar = new ArrayList();
       bar.add("foo");
       request.setAttribute("bar", bar);
    %>
    <jc:foo list="${bar}"/>
        public void setList(List theList) { ... }
    Can't I just
    feed the object into the tag as an object?Not directly. The List you create in the scriptlet has a limited scope, just inside the _jspService method.  This scope isn't really available to things like tags and EL, so you have to put it in a scope where it can be found - something like the request, or page scopes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Converting a class object back to a .class file

    Hi,
    How can i convert a class object back to a .class file ? Thanks

    any pointers on how to do it then ? i don't have
    access to the native codeIf I have understood you correctly, you have native code that generates bytecode. Currently you load the class this bytecode represents right into the classloader, but you want to save it to disk as a .class file. Right?
    If so, you just have to get hold of that bytecode before it "disappears" into the classloader, and save it to disk. How you can best do this depends on exactly how you communicate with that native code.
    If I have misunderstood your problem (and that's not unlikely), please try to be clearer.

  • Use OBJCLASS object of Emigall for  Class & characteristics creation in FL

    Hi Fritz,
    Good day,
    I want to use OBJCLASS object of Emigall for
    Class and characteristics cration of Functional Location, The object is
    desiged for Equipment only,
    I read the document of this object which says
    that it can be modify to use for functional location as well by changing
    some rule, I tried by changing the field "Name of database table for
    object" from the standard which is made for DEVICE/EQUIPMENT
    I need your help to modify the rule to use this object for class and
    characterstic creation for Functional Location, the migration object field is set to Device
    which I want to change to FUNCLOC  but that field is not modifiable.
    Can you help me Fritz
    Regards,
    Robert

    Robert,
    Yes you are right. The following changes have to be made:
    HEADER-OBJECT_TYPE need to be set to IFLOT (Fixed Value or Transfer field rule)
    DATA-FIELD need to be set to TPLNR  (Fixed Value or Transfer field rule)
    DATA-VALUE need to be set to either CONNOBJ or DEVLOC (Via KSM field rule)
    Kind regards,
    Fritz

  • Problem with return a ColdFusion query object from a Java class

    Hi!
    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    "coldfusion.sql.QueryTable")>
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (QueryUtil.java)
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    QueryTable)
    import com.allaire.cfx //(cfx.jar for class Query used from
    QueryTable)
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute QueryUtil.java with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    ok
    i print all my code
    pratica.java execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    my.put("GLOBALS",globals);
    my.put("DBPROP",dbprop);
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    try{
    // Carico il driver JDBC per la connessione con il database
    MySQL
    Class.forName(DRIVER);
    /* Connessione alla base di dati */
    conn=DriverManager.getConnection(URI,LOGIN,PWD);
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    System.out.flush();
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    System.out.flush();
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    try{
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    rs=stmt.executeQuery(query);
    // while (rs.next()) {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    e.printStackTrace();
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    e.printStackTrace();
    this.close();
    return(ret);
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    statament
    //retstruct CF vede HashMap come struct
    //METODO DI TEST
    public HashMap retstruct(){
    return(my);
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    try{
    conn.close();
    conn=null;
    catch (Exception e) {
    e.printStackTrace();
    coldfusion code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Test JDBC CFML Using CFScript</title>
    </head>
    <body>
    <cftry>
    <cfset glb_map =
    createObject("java","java.util.HashMap")>
    <cfset dbprop_map =
    createObject("java","java.util.HashMap")>
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    <cfset ourQuery
    =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
    <cfcatch>
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    </cfcatch>
    </cftry>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    </body>
    </html>
    error at line <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    -----------------------------------------------------------------------

  • How to  get the profile object in simple java class  (Property accessor)

    Hi All,
    Please guide me how to get the profile object in simple java class (Property accessor) which is extending the RepositoryPropertyDescriptor.
    I have one requirement where i need the profile object i.e i have store id which is tied to profile .so i need the profile object in the property accessor of the SKU item descriptor property, which is extending RepositoryPropertyDescriptor.
    a.I dont have request object also to do request.resolvename.
    b.It is not a component to create setter and getter.It is simple java class which is extending the RepositoryPropertyDescriptor.
    Advance Thanks.

    Iam afraid you might run into synchronization issues with it. You are trying to get/set value of property of a sku repository item that is shared across various profiles.
    Say one profile A called setPropertyValue("propertyName", value).Now another profile B accesses
    getPropertyValue() {
    super.getPropertyValue() // Chance of getting value set by Profile A.
    // Perform logic
    There is a chance that profile B getting the value set by Profile A and hence inconsistency.
    How about doing this way??
    Create PropertyDescriptor in Profile (i.e user item descriptor), pass the attribute CustomCatalogTools in userProfile.xml to that property.
    <attribute name="catalogTools" value="atg.commerce.catalog.CustomCatalogTools"/>
    getPropertyValue()
    //You have Profile item descriptor and also storeId property value.
    // Use CustomCatalogTools.findSku();
    // Use storeId, profile repository item, sku repository item to perform the logic
    Here user itemdescriptor getPropertyValue/setPropertyValue is always called by same profile and there is consistency.
    -karthik

  • How to create a new object for a particular class?

    Hi,
      Can anybody please tell  the steps for creating a new object for a particular class.
    Thanks,
    Sreeja

    Declare the object as TYPE REF TO the class and use the CREATE OBJECT statement to create an object.
    DATA <obj_name> TYPE REF TO <class_name>.
    CREATE OBJECT <obj_name>.
    Please mark points if the solution was useful.
    Regards,
    Manoj

  • Exception Handling for many bean objects of a container class in a JSP page

    Hello,
    I have on container bean class. In this container class, there are several others class objects and the getter methods to get these objects out to the JSP pages.
    I have one JSP page which will use different objects in the container class object through the getter methods of the container class.
    My question is how to implement the exception handler for all the objects in the container so that the JSP page can handle all exceptions if occurrs in any object in the container?
    Please give me some suggestions. Thanks
    Tu

    Thanks for your reply.
    Since the container is the accessor class, I have no other super class for this container class, I think I will try the try catch block in the getter methods.

  • Accessing objects in a different class?

    I am now trying to reference a JFileChooser that is in my properties class to a String in my ConfCode class. How would I go about referencing this Object outside of its class? If this makes sense!

    If both classes are located in the same directory, you should be able to call them just like any other class you've imported.
    //source file Class1.java
    public class Class1 {
        public static void main(String[] args) {
         Class2 c2 = new Class2();
         c2.theMethod();
    //source file Class2.java
    public class Class2 {
        public void theMethod() {
         System.out.println("the method was called!");
    }

  • How can I get the "pageContext" object in jsp page?

    Hi everyone:
    I want to get struts's DataSource object in jsp page.So I should get the PageContext object in jsp page.My code is:
    ///////////////////datatest.jsp///////////////////////////////////
         DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    Is right?But I get the "NullPointerException" error in Tomcat.The connection pool in struts-config.xml is:
    <data-sources>
    <data-source key="mydatasource">
    <set-property property="autoCommit"
    value="false"/>
    <set-property property="description"
    value="MyWebSite Data Source Configuration"/>
    <set-property property="driverClass"
    value="org.gjt.mm.mysql.Driver"/>
    <set-property property="maxCount"
    value="4"/>
    <set-property property="minCount"
    value="2"/>
    <set-property property="password"
    value="qijiashe"/>
    <set-property property="url"
    value="jdbc:mysql://localhost:3306/myweb"/>
    <set-property property="user"
    value="lyo"/>
    </data-source>
    </data-sources>
    I can query the database in servlet.
    I think the method that I get the context is not right.Had someone get the pagecontext in jsp page?help :(

    Sorry I forgot that I had change the code:
    DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    to the code:
    DataSource ds=(DataSource)pageContext.getAttribute("mydatasource");
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    mydatasource is the struts datasource in "struts-config.xml". I couldn't work

Maybe you are looking for

  • Error while running Create page in standalone-oc4j

    I have an ADF Create page (CreateAppt.jsp) that works fine through jdeveloper 10.1.3, but does not work when i deploy and run it on a standalone-oc4j. Appreciate your ideas on what may cause this or debugging tips.. My ADF application flows through t

  • My internal hard drive wont show on the desktop and is greyed out in the finder

    My Internal drive will not show up on the desktop, and appears greyed out in the finder. it shows up fine in disk utility and i have tried to repair permissions. This runs normally, there does not seem to be any problems with the drive itself. if i u

  • Configure P6 V7 on Windows 7 professional 32-bit,

    HI, I need to configure P6 V7 on Windows 7 professional 32-bit, I already installed client and oracle client 10g, but it is giving me an error "Bad public user name or password. Database Server Error: ORA-12154: TNS:could not resolve the connect iden

  • Why always hang for the second put? (MUTEX_LOCK)

    Platform: win32 version: 4.7.25.NC App: multi-threaded db_env: db_env_create(&_dbEnv, 0); dbEnv->setcachesize(_dbEnv, 0, 100 * 1024, 0); flags = DB_CREATE \ | DB_INIT_LOCK \ | DB_INIT_MPOOL \ | DB_THREAD; dbEnv->open(dbEnv, home, flags, 0); primary d

  • Good Movement Data Mismatch - Urgent

    Dear Friends, I have exe. the Init of BX,BF and UM and completed the Init of BF and UM with probper marker update procedure.  But I am facing a strange problem. I did the init on 31.01.08 with the R/3 sys down time. I have delete the setup tables for