Aceess a class in the Tomcat 5.0\work\Catalina\localhost

Hi
I need to access a jsp variable in another class. How do i do that. I know that tomcat converts the jsp calss into a java file and puts them in the work\Catalina\localhost folder. So how do i get the variable from the jsp converted java class to my java program..
URGent
thanks
Mansoor

Your design needs some tweaking, I think. That's not quite the right way to go about whatever it is that you're trying to do. If you describe your requirement in more detail, someone might be able to suggest a better way.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
----------------------------------------------------------------

Similar Messages

  • Updating Classes Running in Tomcat

    I am running some JSP's which are using classes. Then I make a change to the class on another machine and recompile the class.
    After this I copy over the existing classes onto the Tomcat server.
    What I have noticed though is that Tomcat is still using the old classes. I have tried stopping Tomcat and restarting it, which does solve the problem.
    Is there any way that I can update the classes without stopping and re-starting Tomcat?
    Reason being is that there may be users currently connected to the web server and stopping it will stop them!

    Some servlet engines support updating classes on the fly and some do not. The ones that do support that usually have a configuration option that allows you to turn it on and off, or to apply it only to certain servlets or directories. I don't know about whether Tomcat supports updating classes on the fly, but if it does you should find some configuration options for it.

  • I want to write in a XML file which is located on the TOMCAT server

    hello all,
    can anybody tell me or give me code snippet for writing some data through my application i.e from client side on te file which is located on the TOMCAT server(especially XML file).
    tell me how can i do that?
    it is urgent
    cya
    sush

    Hello sush,,,,
    I am sending you some API / classes that will definetely help you for writing XML file through java.
    1) TransformerFactory.newInstance();
    2)Transformer serializer
    3)StreamResult
    4)serializer.transform(source,result);
    5)DOMSource
    From Vikas_khengare
    [ [email protected] ]

  • Saving a file in a particular folder over the tomcat server

    I have a java class in the background of a JSP which creates an XML file and saves it.
    Furthermore another class picks that file and processes it. While running this program on my local computer it is obviously working fine but in order to run it on a tomcat server or for that matter any server, I want it to save the XML file in a particular folder, for example:
    tomcat_home/webapps/myapplication/ xmlfolder / something. xml
    so that my other class can easily pick up the file and I dont need to change the location each time I change the server.

    You can get the context root(the place from wher the aplication is running) of your application and then save the file somwhere, but i >>woulden't recomend that. But this is what you are looking for.How ?
    You can also just save the file, it will be saved in a temp directory. (use this only if the file is a temp file not for storing purposes)Just saving the file somehow doesnt work for me as the folder where a class is saving a file by default is somehow different from the folder where another class is trying to pick a file by default. Even if I give no path
    Other option is just to configure a tomcat system variable that specifys an folder. You can get that property from your application and >>then save the files there.Im not able to consider this one because the application will be put on different servers by different people later so they would all then need to configure their systems just to read a file. I was sure there were better ways. :(

  • Putting own custom Writer class in the runtime enviornment of JSP

    Hello All:
    i have a doubt that i have made my own JSPWriter class and i want to use this class to be loaded in the runtime enviornment of the tomcat to get a custom output that is required by me .... for this i have written my own PageContext and through it i am instanciating this writer and successfully using it but is it the right procedure or i shall somehow need to follow some other procedure to get the task done. Another doubt that i have is if i load my suitable classes and in the runtime enviornment, will it effect the other applications that are running on the server ... and what ahould be the ways to overcome this .... is they follow the same procedure as i have then i think they are not supposed to face any problem ... kindly give me suggestions as i am in need of finding a solution as soon as possible ...
    One another thing that i need to ask is that if we want to read the contents that are being sent to the client brower through the JSP then how to get that .....
    I hope you will try to understand my urgency..
    thanks in advance
    Dodo

    Please read http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets8.html#82361 on filters and response wrappers. The advantage to this approach is that you can target your replacement writer to specific web resources and capture output.

  • How to view the tomcat errors in another file

    hi friends,
    i am starting tomcat by using startup.bat, in the console i can see the startupe messages, but when i execute the jsp page it throws some errors, because the window run fast i cannot see the previos errors.
    how to redirect these errors in to a file ???
    i tried using startup.bat > error.txt, but there it is not writing the errors.In tomcat logs also i cannot see the errrors.
    can any one telll how to see this
    thanks
    vin

    Tomcat uses the log4j API. You can put a log4j.properties file in your application classpath (WEB-INF/classes/log4j.properties) and in that properties file you can redirect tomcat log output to a file. The content could be like this:
    log4j.properties:
    # a default stdout console appender. When debugging from an IDE, this will end up in the output window
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
    # tomcat file log appender
    log4j.appender.TA=org.apache.log4j.FileAppender
    log4j.appender.TA.layout=org.apache.log4j.PatternLayout
    log4j.appender.TA.layout.ConversionPattern=%d %p [%c] - %m%n
    log4j.appender.TA.File=c:/log/tomcat.log
    log4j.appender.TA.append=true
    # configure the tomcat logger to use the tomcat file appender. Only warnings and higher are sent to the logfile
    log4j.logger.org.apache=WARN, TA
    Check out the log4j documentation for more details.
    Edited by: gimbal2 on Feb 5, 2008 3:19 PM

  • Class loading in Tomcat server

    Hi,
    I need to specify a class in web.xml or server.xml or any where else, but it shouldnot look for the class during my server startup, it should look only during my application running time. How can I achieve this in Tomcat server?
    thanks

    kasim wrote:
    thanks for the reply.
    I have specified driver class details in context.xml file of Tomcat(5.5), server starts looking up for classes during tomcat server startup, I need to avoid this. So is there anyway to specify my db details in some XML and that shouldnot look for the classes during server start-up time?
    Assuming you're talking about database connections, use the Resource mechanism to manage your database connection pools. Your program shouldn't have to deal with the details of database connection.
    You specify all the database connection info in context or server.xml, and your program accesses them through JNDI, it's all detailed in the Tomcat documentation.

  • Truncated class names on Tomcat, Solaris 10

    Guys, I installed tomcat 5.0.28 and 5.5.20 on Solaris 10. They start with no problem, but when trying to execute the examples, I get a 404 error. It{s because the deployed classes names are truncated:
    on /var/tomcat/webapps/jsp-examples/WEB-INF/classes/org/apache/jsp/jsp2/el, the content is:
    [code]
    basic_002darithmeti
    basic_002dcompariso
    functions_jsp.class
    implicit_002dobject
    It's happening in both versions. ANY HINT/CLUE/HELP?
    Thanks,
    Vladimir

    It won't work if the deployed Class Names don't match exactly with the Class Names that are in the files.
    Your only solution would be to either shorten the class names in both the file name and the name of the class inside the file, or
    keep the file names in their full form as they were originally.

  • JSP, Servlet, and Java Classes location in Tomcat

    In tomcat, I want to know JSP files, Servlets, and Java classes
    should put in different locations:
    I put web.xml in the following:
    C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF
    I put all JSP files in the following:
    C:\jakarta-tomcat-4.1.30\webapps\proj1
    I put all servlet files in the following:
    C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes
    I put all Java classes in the following with package proj1:
    C:\jakarta-tomcat-4.1.30\webapps\proj1\WEB-INF\classes\proj1
    When I execute JSP files, it has HTTP error 404, file not found.
    The content of web.xml is:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>proj1</display-name>
    <description>
         proj1
    </description>
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    </web-app>
    Please advise. thanks!!!

    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    </web-app>Where's the servlet definition that maps to "invoker"?

  • Can not call bean class from JSp/Tomcat 5.5

    hello everyone...
    i m using one bean class Parser which is called by discussion.jsp page. i put class file in webapps/grid/WEB-INF/classes and JSP page is in webapps/grid/. The whole combination is working fine for tomcat 3.3.2 but not working properly in tomcat 5.5.
    Error is as follow...
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 38 in the jsp file: /discussion.jsp
    Generated servlet error:
    Parser cannot be resolved or is not a typeplease help me....
    Thank in Advance

    You still need to import the class from the default package. As a word of advice you should put the class in a package. The later versions of Tomcat do not play well with bean classes that are not in packages.

  • How to configure implementation class in the deployment descriptor?

    i'm tring to add <listener> element to my web application. the web server is Apache plus Tomcat(3.2.3), and i add the following line to WEB.XML of Tomcat:
    <listener>
    <listener-class>
    com.listeners.MySessionListener
    </listener-class>
    </listener>
    <listener>
    <listener-class>
    com.listeners.ServletContextAttribListener
    </listener-class>
    </listener>
    <listener>
    <listener-class>
    com.listeners.MySessionListener
    </listener-class>
    </listener>
    (according to the direction of http://forum.java.sun.com/thread.jsp?forum=45&thread=150088. i have read the article in detail)
    but nothing happened. when i make changes in the jsp page, nothing was noted in the the tomcat output window. i've got the MySessionListener.class and put it in the proper folder.
    where should i add the <listener> element? can HttpSessionBindingListener or HttpSessionListener work without adding the elements to web application configuration?
    thanks for your help and previous discussion!
    best regards.

    Hi
    The Listener features are part of Servlet specification 2.3 which is supported by Tomcat 4.0 beta 7. Tomcat 3.2.3 supports Servlet specification 2.2.
    To use listeners use Tomcat 4.0 beta version 7.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • Thread to shut the tomcat and restart

    THIS IS WHAT I AM TRYING TO DO BUT AFTER STARTING THE TOMCAT MY THREAD IS NOT WAKING UP
    HELP PLEASE
    class Restarts extends Thread{
         String fileStart="",fileRestart="";     
         String line,line1;
         public Restarts(String start1, String restart1){
              fileStart=start1;
              fileRestart=restart1;
              start();
         public void run(){
              try{
                   Process p = Runtime.getRuntime().exec(fileStart);
                   BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                   while ((line = input.readLine()) != null) {
                   System.out.println(line);
                   input.close();     
                   sleep(20000);
                   Process p1 = Runtime.getRuntime().exec(fileRestart);
                   BufferedReader input1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                   while ((line1 = input1.readLine()) != null) {
                   System.out.println(line1);
                   input1.close();
              catch(Exception e){
                   e.printStackTrace();
    class Restart
         public static void main(String a[]){
              Restarts start = new Restarts("startup.bat","shutdown.bat");
    }

    Quit Mail. Force quit if necessary.
    Back up all data. That means you know you can restore the Mail database, no matter what happens.
    Triple-click the line below on this page to select it:
    ~/Library/Mail/V2/MailData/Envelope Index
    Copy the selected text to the Clipboard (command-C). In the Finder, select
    Go ▹ Go to Folder
    from the menu bar. Paste into the box that opens (command-V), then press return.
    A Finder window will open with a file selected. Move the selected file to the Desktop, leaving the window open. Other files in the folder may have names that begin with "Envelope Index". Move those files, if any, to the Trash.
    Log out and log back in. Relaunch Mail. It should prompt you to re-import your messages. You may get a warning that the index is corrupt and that Mail has to quit. Click OK.
    Test. If Mail now works as expected, you can delete the file you moved to the Desktop. Otherwise, post your results.

  • How to redirect the tomcat (5.0) console output to a text file

    Hello,
    I am looking for a way of redirecting the tomcat console output [the System.out.println("xyzabc")�s from the java classes running on the container] to a text file.
    The reason is that the programmers need to have that console�s output and the server (windows) have to be rebooted often (no wonder: windows) and then Tomcat start as a service -> console is not visible.
    Thanks!

    The console out put should still be in the log files if tomcat is running as a windows service. It will either be in logs\stdout_xxxx.log and logs\stderr_xxxx.log or in logs\catalina.xxxx.log.
    If you are using 5.5.
    It will either be in logs\stdout.log and logs\stderr.log or in logs\catalina.out.
    if you are using 5.0

  • The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the

    Hi,
    Im trying to create a Rest WS with a @GET method that will return me an Emp object. I need the output as a JSON string.
    I have created a dynamic web project and added javax RS jars:
    When im trying to run this, i'm getting the below mentioned error:
    FlushResultHa E org.apache.wink.server.internal.handlers.FlushResultHandler handleResponse The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.
    RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error)
    Please help as im stuck with this from long.
    Thanks in advance.
    Below is the code for my service class:
    package com.rest.assignment;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.HashSet;
    import java.util.Properties;
    import java.util.Set;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.Application;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;
    @Path("/restService")
    public class RestService extends Application {   
        @GET
        @Path("/getEmpDetails")
        @Produces(MediaType.APPLICATION_JSON)
        public Response getStringResponse()
            EmpBean empBean = new EmpBean();
            String filePath = "C:/Program Files/IBM/workspace/HelloWorld/src/com/rest/resources/EmpData.properties";
            Properties properties = new Properties();
            try {
                properties.load(new FileInputStream(filePath));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
             Enumeration e = properties.propertyNames();
             String result="";
            String[] empDetailsArr;
            while (e.hasMoreElements()) {
              String key = (String) e.nextElement();
              String empDetails = properties.getProperty(key);
              empDetailsArr=empDetails.split(",");    
              empBean.setFirstName(empDetailsArr[0]);
              empBean.setLastName(empDetailsArr[1]);
              empBean.setEmpId(empDetailsArr[2]);
              empBean.setDesignation(empDetailsArr[3]);
              empBean.setSkillSet(empDetailsArr[4]);
              result = empDetailsArr[1];
            //return empBean;
            return Response.ok(empBean).type(MediaType.APPLICATION_JSON_TYPE).build();
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(RestService.class);
            classes.add(EmpBean.class);
            return classes;
    and my empBean goes like this:
    package com.rest.assignment;
    public class EmpBean {
        private String firstName;
        private String lastName;
        private String empId;
        private String designation;
        private String skillSet;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getEmpId() {
            return empId;
        public void setEmpId(String empId) {
            this.empId = empId;
        public String getDesignation() {
            return designation;
        public void setDesignation(String designation) {
            this.designation = designation;
        public String getSkillSet() {
            return skillSet;
        public void setSkillSet(String skillSet) {
            this.skillSet = skillSet;
    Web.xml goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>restWS</display-name>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
      <servlet-name>REST</servlet-name>
      <servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
      <init-param>
       <param-name>javax.ws.rs.Application</param-name>
       <param-value>com.rest.assignment.RestService</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>REST</servlet-name>
      <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    </web-app>
    When i try to return a string from my get method, it gives me a proper response. i get this exception when im trying to return a JSON response.

    Hi,
    Im trying to create a Rest WS with a @GET method that will return me an Emp object. I need the output as a JSON string.
    I have created a dynamic web project and added javax RS jars:
    When im trying to run this, i'm getting the below mentioned error:
    FlushResultHa E org.apache.wink.server.internal.handlers.FlushResultHandler handleResponse The system could not find a javax.ws.rs.ext.MessageBodyWriter or a DataSourceProvider class for the com.rest.assignment.EmpBean type and application/json mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the JAX-RS application for the type and media type specified.
    RequestProces I org.apache.wink.server.internal.RequestProcessor logException The following error occurred during the invocation of the handlers chain: WebApplicationException (500 - Internal Server Error)
    Please help as im stuck with this from long.
    Thanks in advance.
    Below is the code for my service class:
    package com.rest.assignment;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.HashSet;
    import java.util.Properties;
    import java.util.Set;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import javax.ws.rs.core.Application;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.core.Response;
    @Path("/restService")
    public class RestService extends Application {   
        @GET
        @Path("/getEmpDetails")
        @Produces(MediaType.APPLICATION_JSON)
        public Response getStringResponse()
            EmpBean empBean = new EmpBean();
            String filePath = "C:/Program Files/IBM/workspace/HelloWorld/src/com/rest/resources/EmpData.properties";
            Properties properties = new Properties();
            try {
                properties.load(new FileInputStream(filePath));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
             Enumeration e = properties.propertyNames();
             String result="";
            String[] empDetailsArr;
            while (e.hasMoreElements()) {
              String key = (String) e.nextElement();
              String empDetails = properties.getProperty(key);
              empDetailsArr=empDetails.split(",");    
              empBean.setFirstName(empDetailsArr[0]);
              empBean.setLastName(empDetailsArr[1]);
              empBean.setEmpId(empDetailsArr[2]);
              empBean.setDesignation(empDetailsArr[3]);
              empBean.setSkillSet(empDetailsArr[4]);
              result = empDetailsArr[1];
            //return empBean;
            return Response.ok(empBean).type(MediaType.APPLICATION_JSON_TYPE).build();
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> classes = new HashSet<Class<?>>();
            classes.add(RestService.class);
            classes.add(EmpBean.class);
            return classes;
    and my empBean goes like this:
    package com.rest.assignment;
    public class EmpBean {
        private String firstName;
        private String lastName;
        private String empId;
        private String designation;
        private String skillSet;
        public String getFirstName() {
            return firstName;
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        public String getLastName() {
            return lastName;
        public void setLastName(String lastName) {
            this.lastName = lastName;
        public String getEmpId() {
            return empId;
        public void setEmpId(String empId) {
            this.empId = empId;
        public String getDesignation() {
            return designation;
        public void setDesignation(String designation) {
            this.designation = designation;
        public String getSkillSet() {
            return skillSet;
        public void setSkillSet(String skillSet) {
            this.skillSet = skillSet;
    Web.xml goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>restWS</display-name>
    <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
      <servlet-name>REST</servlet-name>
      <servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
      <init-param>
       <param-name>javax.ws.rs.Application</param-name>
       <param-value>com.rest.assignment.RestService</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>REST</servlet-name>
      <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    </web-app>
    When i try to return a string from my get method, it gives me a proper response. i get this exception when im trying to return a JSON response.

  • Can We Use Multiple Edgehero Classes On The Same Element?

    Does anyone know if it is possible to add multiple Edgehero classes to the same element? More specifically, I would like to use RotateX and RotateY on a rectangle, but it only seems to do one or the other, adding both classes to the element doesn't make it rotate in both directions.

    Maybe check out the Star Wars demo to see if that would help.
    Rob got the idea from the one I made earlier and here is the code:
    sym.$('gradient').css('background', '-moz-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-moz-transform-origin', '50% 100%');
    sym.$('container').css('-moz-transform', 'perspective(250px) rotateX(25deg)');
    // Chrome and others
    sym.$('gradient').css('background', '-webkit-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-webkit-transform-origin', '50% 100%');
    sym.$('container').css('-webkit-transform', 'perspective(250px) rotateX(25deg)');
    // Internet Explorer
    sym.$('gradient').css('background', '-ms-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-ms-transform-origin', '50% 100%');
    sym.$('container').css('-ms-transform', 'perspective(250px) rotateX(25deg)');
    and the orginal file before edgeHero;
    https://app.box.com/s/068vx5x6lj5t2yydrx17

Maybe you are looking for