Using HttpServletRequest object to share variables between static methods.

Does anyone know of the overhead/performance implications of using the HttpServletRequest object to share variables between a static method and the calling code?
First, let me explain why I am doing it.
I have some pagination code that I would like to share across multiple servlets. So I pulled the pagination code out, and created a static method that these servlets could all use for their pagination.
public class Pagination {
     public static void setPagination (HttpServletRequest request, Config conf, int totalRows) {
          int page = 0;
          if (request.getParameter("page") != null) {
               page = new Integer(request.getParameter("page")).intValue();
          int articlesPerPage = conf.getArticlesPerPage();
          int pageBoundary = conf.getPageBoundary();
            int numOfPages = totalRows / articlesPerPage;  
            // Checks if the page variable is empty (not set)
            if (page == 0 || (page > numOfPages && (totalRows % articlesPerPage) == 0 && page < numOfPages + 1)) {    
             page = 1;  // If it is empty, we're on page 1
          // Ex: (2 * 25) - 25 = 25 <- data starts at 25
         int startRow = page * articlesPerPage - (articlesPerPage);
         int endRow = startRow + (articlesPerPage);           
         // Set array of page numbers.
         int minDisplayPage = page - pageBoundary;
         if (minDisplayPage < 1) {
              minDisplayPage = 1;     
         int maxDisplayPage = page + pageBoundary;
         if (maxDisplayPage > numOfPages) {
              maxDisplayPage = numOfPages;     
         int arraySize = (maxDisplayPage - minDisplayPage) + 1;
         // Check if there is a remainder page (partially filled page).
         if ((totalRows % articlesPerPage) != 0) arraySize++;
         // Set array to correct size.
         int[] pages = new int[arraySize];
         // Fill the array.
         for (int i = 1; i <= pages.length; i++) {
              pages[i - 1] = i;
         // Set pageNext and pagePrev variables.
         if (page != 1) {
              int pagePrev = page - 1;
              request.setAttribute("pagePrev", pagePrev);
         if ((totalRows - (articlesPerPage * page)) > 0) {
             int pageNext = page + 1;
             request.setAttribute("pageNext", pageNext);
         // These will be used by calling code for SQL query.
         request.setAttribute("startRow", startRow);
         request.setAttribute("endRow", endRow);
         // These will be used in JSP page.
         request.setAttribute("totalRows", totalRows);
         request.setAttribute("numOfPages", numOfPages);
         request.setAttribute("page", page);
         request.setAttribute("pages", pages);          
}I need two parameters from this method (startrow and endrow) so I can perform my SQL queries. Since this is a multithreaded app, I do not want to use class variables that I will later retrieve through methods.
So my solution was to just set the two parameters in the request and grab them later with the calling code like this:
// Set pagination
Pagination.setPagination(request, conf, tl.getTotalRows());
// Grab variables set into request by static method
int startRow = new Integer(request.getAttribute("startRow").toString());
int endRow = new Integer(request.getAttribute("endRow").toString());
// Use startRow and endRow for SQL query below...Does anyone see any problem with this from a resource/performance standpoint? Any idea on what the overhead is in using the HttpServletRequest object like this to pass variables around?
Thanks for any thoughts.

You could either
- create instance vars in both controllers and set them accordingly to point to the same object (from the App Delegate) OR
- create an instance variable on the App Delegate and access it from within the view controllers
Hope this helps!

Similar Messages

  • Share variables between JSP and Classes

    Hello !
    Is there any way to share the same variables between JSP�s and Classes?
    For example...
    I have 20 variables in a JSP page (with values, like constants...) and I want to view their contents inside the classes...
    Is there any way? Maybe a import or something like this...
    Thanks,
    Igor.

    If you search the forums you will find many answers to your questions. You can also try the servlet and JSP short courses listed below;
    Here is lthe link that will take you to the Java.sun.com Tutorial pages.
    http://developer.java.sun.com/developer/onlineTraining/
    Here is a tutorial on Servlets
    http://developer.java.sun.com/developer/onlineTraining/Servlets/Fundamentals/contents.html
    Here is the tutorial on the JSP
    http://developer.java.sun.com/developer/onlineTraining/JSPIntro/contents.html

  • Can I use C++ objects as Host variables in Pro*C++

    Hi,
    I have a C++ object in my Pro*C++ program. The objects has
    members representing all the fields of a oracle table record.
    e.g. For a table TEST_PRODUCT ( product_id, name),
    the C++ class is :
    class prd
    public:
    int id;
    char name[50];
    Can I use the Object of this class as a Host Variable ? In SQL
    select query , I want to directly fetch record into this object.
    When I declare this object within EXEC SQL BEGIN DECLARE SECTION
    and END DECLARE SECTION , it gives me compilation error.
    Is that supported by Pro*C++ ? If yes, how to do it?
    Pls help.
    Thanks

    I find it easier to decalre a local variable in the EXEC SQL
    block and then assign that to your class variable at the end of
    the statement. It makes it easy to check for nulls and db
    errors without affecting the C++ object.
    PT

  • How share variables between classes ???

    Hi !
    Basically I have two classes and I would like them to share a variable, I mean, when I modify it on one class the other one is also affected.
    how can I do that ? by using the inheritance principle or is it a simple way so that we don't have one more class??
    thank you a lot for your answer !
    PA

    If you want them to always have the same value, you should have only one variable:public class ClassOne
      private static int theVar = 0;
      public static void setTheVar(int value){theVar = value;}
      public static int getTheVar(){return theVar;}
    public class ClassTwo
      public static int getTheVar(){return ClassOne.getTheVar();}
    }

  • Using events (?) to share data between tab pages

    I don't know whether this is an event question or an Object-Oriented design question or a JTabbedPane question.
    I'm pretty new to Java, so be patient!
    I wish to have a JTabbedPane with a tab to do 'Import' of data, and a tab to do 'Export' of data (the SAME data which was imported). Now, how do I share the data between the 2 tabs?
    It seems the data belongs at the JFrame level, but then how does the data in each tab access it? In other languages I would pass a reference to the data object in the window to each tab.
    Or how do I get (or set) the data when the tab changes? And how do I know when the tab changes?
    I think I need to set trigger some sort of event to the parent window, who I suppose has a listener, and then it can then query the appropriate pane? If so, I'm not sure what sort of event trigger I should be using, where etc.
    I know if I had one tab with an import/export functionality then I could declare the Collection within that panel.
    Help!!!
    Thanks ;)

    I think this is an OO design question.
    You basically have two views (the two panes) of the same data. So I'd suggest the Observer pattern (see the Design Patterns book) where one model holds the data and the model is observed by several views.

  • In a dynamic page how to share variable between PL/SQL and javascript

    For example, my dynamic page contains such PL/SQL codes:
    <ORACLE>
    DECLARE
    info varchar(100);
    rowid urowid;
    procedure doDelete(
    row_id in urowid
    ) IS
    begin
    Delete From xxx
    WHERE rowid = row_id;
    end doDelete;
    BEGIN
    Select name, rowid INTO info, rowid
    From xxx Where xxx;
    HTP.PRN(' <INPUT TYPE="button" VALUE="show value" onClick="alert(info);">');
    HTP.PRN(' <INPUT TYPE="button" VALUE="delete" onClick="doDelete(_row_id);">');
    END;
    </ORACLE>
    The variable 'info' and '_row_id' are correct, however the two HTP. sentence do not work. What's the problem?
    What I want to do is to show all the records in TABLE A in a page. And at the end of each line (record), there' re a 'delete' and a 'update' button to let user operate on this record. Is this possible? I know form can do delete an update, but it can not show all the records in a page like what report does. Besides dynamic page, is there any other better choice? Report can do it?
    One more question. In a report, I employed link on one field to a second report. It works well. But I want to open the second report in a new window when the link is click. Is this possible?
    I was almost driven crazy by these :( I so appreciate if anyone can help.

    The code written by you is insufficient for the funtionality you are trying to achieve. Below is a method to achieve the same.
    Note: Used standard scott.emp table for the example which is located in my db provider schema.
    Do the below modifications as per your local configuration
    xxxxx -> Replace it with your Portal schema
    yyyyy -> Replace it with your db provider schema
    <<module_id_of_form>> -> Replace with the module id of form created in step 1 & 2.
    First and foremost... oracle does not allows variables starting with '_'. So if you want to use it you have to place it in double quotes ("")
    rowid -> illegal
    "_row_id" -> legal.
    However, I will advice you not to use variable names starting with "_".
    Now lets get started...
    1. Create a form on the table you are using in the dynamic page. Just have the update button. Remove the other buttons.
    2. Get the module id of this form. Instruction for getting the module id:
    a) Right-click on the form's run link and copy the shortcut
    b) Get the value of p_moduleid parameter. This is your module id.
    3. Create a procedure "save_action_details" in your db provider schema. This procedure will accomplish the delete operation on the record.
         CREATE OR REPLACE Procedure save_action_details(
         p_rowid IN VARCHAR2,
         p_action IN VARCHAR2,
         p_dyn_ref_path IN VARCHAR2,
         p_dyn_page_url IN VARCHAR2)
         is
         l_sto_session xxxxx.wwsto_api_session;
         begin
         l_sto_session := xxxxx.wwsto_api_session.load_session(
         p_domain => 'DynStore',
         p_sub_domain => 'DynStore_' || p_dyn_ref_path
         l_sto_session.set_attribute(
         p_name => 'rowid',
         p_value => p_rowid
         l_sto_session.set_attribute(
         p_name => 'action',
         p_value => p_action
         l_sto_session.save_session;
         htp.init;
         owa_util.redirect_url(p_dyn_page_url);
         end save_action_details;
    Explaination: The above procedure creates a session and keeps the rowid and action in the session. This information is used by the below dynamic form to perform the necessary action. In our exampl, the action is always going to be delete so you may go ahead and hard code it, else leave it as it is.
    4. Grant execute privilege on the procedure "save_action_details" to public.
    sql> grant execute on save_action_details to public;
    5. Create your Dynamic page.
    a) In HTML code section have the below code. This code shows some columns from the table and "update" and "delete" buttons to perform the respective action.
         <ORACLE>select empno,ename,rowid,
         '<input type="button" value="Update" onClick="doAction(this.form,''UPD'',''xxx'','''
         || xxxxx.wwv_standard_util.url_encode(rowid) || '''); tWin();">
         <input type="button" value="delete" onclick="doAction(this.form,''DEL'',''' || rowid || ''',''xxx'');">' Action
         from yyyyy.emp</ORACLE>
    b) In additional pl/sql code section of dynamic page, have the below pl/sql block "in after displaying the header" section.
         declare
         l_sto_session xxxxx.wwsto_api_session;
         l_del_rowid varchar2(20);
         l_action varchar2(10);
         begin
         htp.comment('User code starts here ...');
         htp.p('<script>');
         htp.p('var winHandle;');
         htp.p('
         function doAction(formObj, action, rowid, erowid)
              if (action == "UPD")
              var formURL = "' || xxxxx.wwctx_api.get_proc_path('wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=<<module_id_of_form>>&p_arg_names=_rowid&p_arg_values=') || '" + erowid;
              winHandle = window.open(formURL, "winDynUpd", "width=750,height=500,resizable=yes");
              else
              formObj.p_rowid.value = rowid;
              formObj.p_action.value = action;
              formObj.submit();
         function tWin() {
              if (winHandle.closed) {
              document.location = document.location;
              else {
              setTimeout("tWin()", 500);
         htp.p('</script>');
         htp.p('<form name="dynRowProcess" method="POST" action="'
         || xxxxx.wwctx_api.get_proc_path('save_action_details','yyyyy')
         || '">');
         htp.p('<input type="hidden" name="p_rowid">');
         htp.p('<input type="hidden" name="p_action">');
         htp.p('<input type="hidden" name="p_dyn_ref_path" value="' || p_reference_path || '">');
         htp.p('<input type="hidden" name="p_dyn_page_url" value="' || p_page_url || '">');
         l_sto_session := xxxxx.wwsto_api_session.load_session(
         p_domain => 'DynStore',
         p_sub_domain => 'DynStore_' || p_reference_path
         l_del_rowid := l_sto_session.get_attribute_as_varchar2('rowid');
         l_action := l_sto_session.get_attribute_as_varchar2('action');
         if l_action = 'DEL' then
         delete from yyyyy.emp
         where rowid = l_del_rowid;
         end if;
         end;
    Explaination: The session information (rowid and action) stored by "save_action_details" procedure is retrieved by the dynamic page and is used to delete the record.
    6. Once you are through with the above steps, test it by placing the above "dynamic page" portlet on a page.
    a) When you click on delete button the record gets deleted and the automatically refreshed page will not show the deleted record.
    b) On clicking update button, a form will appear. do the necessary modifications in data and click update. the data in the form gets updated. Once you close the form the dynamic page gets refreshed automatically and it will show you the updated information.

  • How to share variable between jsp and JSF?

    hi:
    I have code :
    <h:dataTable binding="#{Tables.dataTable}" value="#{Tables.query}" var="currentRow">
    <h:column>
    <h:outputText value="#{currentRow['factorycode']}"/>
    </h:column>
    <%
    //here I want get upon variable currentRow and process some field.
    // but how java code I can get the currentRow,
    //currentRow is a ResultSet object
    %>
    </h:dataTable>
    thanks

    EL cannot pick up scripting variables. It picks up attributes from scope only.
    Similarly it doesnt set any scripting variables too.
    <%
                  int g_nAge=12;
                  pageContext.setAttribute ("g_nAge", new Integer(g_nAge));
    %>
    ${g_nAge}cheers,
    ram.

  • How to share variable between

    HI, I want to write a program with two classes, and there is a variable that should be shared between these two classes. I don't know how to realize the sharing. Thanks

    Here you go:class A {
       // whatever type T is ...
       private T sharedVariable;
       // get/set it
       public void setSharedVariable(T that) { sharedVariable= that; }
       public T getSharedVariable() { return sharedVariable; }
       // etc. etc.
    class B {
       private A a;
       // pass the stuff to be shared ...
       public B(A a) { this.a= a; }
       // get/set it
       public void setSharedVariable(T that); { a.setSharedVariable(that); }
       public T getSharedVariable() { return a.getSharedVariable(); }
       // etc. etc.
    }kind regards,
    Jos

  • Getting Server IP Address using HttpServletRequest object

    Hi
    I am writing code using servlets ,
    My system is on LAN let say its IP is suppose 192.0.0.1 and i have another computer name "A" on Lan with private ip 192.0.0.2 and also its has public IP 12.0.0.10 suppose.
    When i recive request from i try to get its public IP using methods
    request .getRemoteAddress(), but problem is i am getting its private IP i want to get its public Ip how i can get it

    Are you running dual network interfaces in each machine?
    If so, and the packet you're attempting to analyze for public IP address is being received over the local network, I don't think there's a way to accomplish this outside building a lookup table or some such manually.
    Or is there some sort of "fun" routing system in place here?
    ...or have I completely misunderstood the question? :)
    -Kyle

  • How do I use Home Sharing to share apps between multiple Apple ID accounts on differect PCs in the same house?

    I purchased an app called "Where's My Water?" on my iTunes account. My iTunes account and iTunes library is set up on my desktop PC. Anyway, my mom wanted the app. She has her iTunes account and library set up on our laptop PC. So, I connected both my desktop and her laptop via Home Sharing by entering my account information on both computer's Home Sharing screens. The app was transferred from my library to her library. When I synced her iPod to her PC, it did not move the app to the iPod. So, I figured I would just manually download it off the app store on her iPod and she wouldn't get charged $0.99 because the app was already in her iTunes library. It turns out when I bought the app on her iPod, it actually took out money from her account. I want to know what went wrong. Why didn't the Home Sharing thing work so she could get the app I bought without having to buy it herself?

    The short answer: because Home Sharing isn't designed for sharing apps, and apps aren't designed to be shared.
    The longer answer:  Think of it like this...
    You download some music in iTunes.  With Home Sharing, another user can listen to it by streaming it over the network.  But the data itself is on your computer.  If you turn off the computer or take it off the network, the other user can't access it.
    But if you send another user the app, they aren't just streaming the data- they installed it on their iOS device.  Because they weren't the one that purchased it, such a transfer could easily be considered "piracy" or "stealing," and nobody likes that (least of all, Apple). 
    When iTunes sees this app, it obviously recognized it, as if saying, "Hey, how did you get this app on your device, if I have no record of you purchasing/downloading it from the iTunes store?"
    post edited to correct spelling errors

  • Non-Static Variables in Static Methods

    I've been working away on this today and it's got to the stage where I cannot figure out what the hell is wrong.
    In my static main method I have declared an array a of type Account, which has been declared in its own class. However when I try and do something to the array in another method, which incidentally is static. It claims it cannot find the symbol a, as if it is has not been created at all?
    Any suggestions? Can post code if it helps

    Variables created inside methods can be accessed only from inside the method. If you want to acces such a value from another method you need to
    make it a field (declare outside the method) or pass it as a parameter when you call the second method.

  • Can I share Attributes/Variables between 2 different Class Driver Sessions?

    I am designing a Simulator of Instrumentation following these steps:
    1) re-programming, re-compiling, and re-building the DLLs from the advanced class simulation drivers included in IVI Driver Toolset 2.0 using LabWindows/CVI 7.0;
    2) then i create a VI in LabVIEW 7.0 which calls an IVI Class Driver obtaining the desired simulated output data.
    My problem is that I need to share variables between different DLLs in LabVIEW.
    I want to simulate a circuit which consists of a battery and a resistor. I've got 2 instruments: a DC Power Supply and a Digital Multimeter.
    The DC Power Supply acts as the battery providing a certain voltage level, and the Multimeter measures the Voltage and the Current in the resistor.
    I've designed a VI in LabVIEW which uses 2 different sessions: one which calls the class driver IviDCPwr, and the other one which calls IviDmm.
    I wish to be able to access the attributes from "nisDCPwr.c" in the file "nisDmm.c".
    For example, to write a line like this:
    Ivi_GetAttributeViReal64 (ViSession vi, ViConstString channelName, NISDCPWR_ATTR_MEASUREMENT_BASEV, 0, &reading));
    inside the source code "nisDmm.c" of the advanced class simulation driver.
    The problem is that the only ViSession accessible from nisDmm is the handle from the Digital Multimeter, but not from DC Power Supply.
    Would this be possible? Is it "legal"?
    I've tried another approach through the declaration of external variables, but unfortunately I get a run-time error in LabVIEW.
    The only solution I've found is using auxiliary files going between, through the functions included in the Low Level I/O Library .
    Nevertheless, the solution proposed above would result much more convenient, faster and safer in my application.
    I hope everyone has understood my question, and anyone can help.
    THANK YOU VERY MUCH FOR YOUR TIME!!!

    Doesn't anyone have an answer?
    Or any proposal?
    Or even a clue?
    THANKS!

  • Why not to use static methods - with example

    Hi Everyone,
    I'd like to continue the below thread about "why not to use static methods"
    Why not to use static methods
    with a concrete example.
    In my small application I need to be able to send keystrokes. (java.awt.Robot class is used for this)
    I created the following class for these "operations" with static methods:
    public class KeyboardInput {
         private static Robot r;
         static {
              try {
                   r = new Robot();
              } catch (AWTException e) {
                   throw new RuntimeException(e + "Robot couldn't be initialized.");
         public static void wait(int millis){
              r.delay(millis);
         public static void copy() {
              r.keyPress(KeyEvent.VK_CONTROL);
              r.keyPress(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_C);
              r.keyRelease(KeyEvent.VK_CONTROL);
         public static void altTab() {
              r.keyPress(KeyEvent.VK_ALT);
              r.keyPress(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_TAB);
              r.keyRelease(KeyEvent.VK_ALT);
                   // more methods like  paste(), tab(), shiftTab(), rightArrow()
    }Do you thinks it is a good solution? How could it be improved? I've seen something about Singleton vs. static methods somewhere. Would it be better to use Singleton?
    Thanks for any comments in advance,
    lemonboston

    maheshguruswamy wrote:
    lemonboston wrote:
    maheshguruswamy wrote:
    I think a singleton might be a better approach for you. Just kill the public constructor and provide a getInstance method to provide lazy initialization.Thanks maheshguruswamy for advising on the steps to create a singleton from this class.
    Could you maybe advise also about why do you say that it would be better to use singleton? What's behind it? Thanks!In short, it seems to me that a single instance of your class will be able to coordinate actions across your entire application. So a singleton should be enough.But that doesn't answer why he should prefer a singleton instead over a bunch of static methods. Functionally the two are almost identical. In both cases there's only one "thing" on which to call methods--either a single instance of the class, or the class itself.
    To answer the question, the main reason to use a Singleton over a classful of static methods is the same reason the drives a lot of non-static vs. static decisions: Polymorphism.
    If you use a Singleton (and and interface), you can do something like this:
    KeyboardInput kbi = get_some_instance_of_some_class_that_implements_KeyboardInput_somehow_maybe_from_a_factory();And then whatever is calling KBI's public methods only has to know that it has an implementor of that interface, without caring which concrete class it is, and you can substitute whatever implementation is appropriate in a given context. If you don't need to do that, then the static method approach is probably sufficient.
    There are other reasons that may suggest a Singleton--serialization, persistence, use as a JavaBean pop to mind--but they're less common and less compelling in my experience.
    And finally, if this thing maintains any state between method calls, although you can handle that with static member variables, it's more in keeping with the OO paradigm to make them non-static fields of an instance of that class.

  • Problem Sharing Variables between 2 machines

    I am having problems trying to create a project that would share variables between multiple computers. I am using Labview 8.2.1 (I am new to 8.2.1 and Shared Variable).
    here is what i did:
    1. I created the project with Client and Server VI's and a library containing shared variables, which both of them call
    2. I placed this project onto 2 computers (XP on a local workgroup, no firewall, see each other).
    3.  On one of the computers I bound all shared variables to their counterparts on the other computer
    The system is "almost working"
    The problems are:
    - I initially used wrong type variables for few items. I then modified the variables in both VI's and Shared Variable libraries and repeated the Steps 1-3 above.
    But the sysrtem has some sort of a buffer somwhere, because it keeps bringing the old types of shared variables back (when I monitor them using Shared Variable Monitor).
    - When I do binding to source, the system shows wrong variable types (for example DBL instead of U8).
    - It takes almost a second to write and read shared variable (my network is quite fast)
    I saw that the Labview Example with Server and multiple Clients uses 2 sets of shared variable and they bind - separate sets (different names) fro client and server within the same project. Do I have to do this or is this done just to simplify bindinga nd future distribution?
    Is there a buffer/setup/file that I need to clear to get rid of "old" shared variable assignements? (I tried undeploy/deploy - does not help...)
    Thank you very much,
    Gleb.

    Hi Gleb,
    It sounds like the shared variable is not getting completely undeployed from the shared variable engine.  I would recommend opening the shared variable manager and undeploying the library from there just to see that it is no longer in the engine.  Then, redeploy the library and rebind your variables to the host library that you have deployed.
    It is not necessary to have different sets of variables for client and host.  The important part of the variable is what it is bound to, not necessarily what it is named.  So just undeploy your variable, double check the settings of the host variable, then redeploy using the variable manager and rebind your client variables. 
    I hope this helps,
    Brian Coalson
    Software Engineer
    National Instruments

  • How do I share files between users on the same machine?

    I tried using /Users/shared to share files between myself (Admin user) and another user on the machine (Standard user). Whenever I put a file or a folder into said directory permissions are 755 for directories and 644 for files, my umask is 0022. The files and directories belong to my user and the group staff. This means I can read and write and others can read. If I do the same using the other users account. Permissions are 700 and 600 respectively. (Owner is the other user and group is staff.) Strangely the other users umask is 0022, too.
    The result is, that all directories and files I create with my account (Admin user) are readable to every other user on the machine, whereas all directories and files the other user (Standard user) creates are not readable for anyone else. I can easily rectify this using the Terminal and chmod and/or chown, but it is a pain having to do this, since I also need to forcefully restart the Finder App for it to notice the changed permissions.
    Ideally I'd like all directories in /Users/Shared to have permissions 777 and all files 666 no matter which user created, copied or moved them to said location. I think this could possibly be done using applescript and shellscripting and the folder action hook. So far my attempts to find such a script on the net or/and write it myself have failed. I'd be grateful for any hints how I:
    a) write and setup such a script
    b) accomplish what I try to do (share files and folders on the same machine) in another possibly more Mac way
    Kind regards
    David

    The following AppleScript will recursively descend the directory tree and change the items to your modes:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on adding folder items to this_folder after receiving these_items
    repeat with some_item in these_items
    ProcessStuff from some_item
    end repeat
    end adding folder items to
    to ProcessStuff from SomeItem
    processes items contained in SomeItem, recursively descending the directory tree
    parameters - SomeItem [mixed]: an item containing the items to process
    returns nothing
    set SomeItem to SomeItem as text
    set FileInfo to (info for SomeItem as alias)
    if (folder of FileInfo) and not (package folder of FileInfo) then -- a folder (not a package)
    do shell script "chmod 666 " & quoted form of POSIX path of SomeItem
    -- do shell script "chown root:staff " & quoted form of POSIX path of SomeItem user name "me" password "mypassword" with administrator privileges
    try -- to get items in the folder
    tell application "Finder" to set SubFolder to (items of folder SomeItem)
    on error
    return {}
    end try
    repeat with SubItem in SubFolder -- process the sub items
    ProcessStuff from SubItem
    end repeat
    else -- a file
    do shell script "chmod 777 " & quoted form of POSIX path of SomeItem
    -- do shell script "chown root:staff " & quoted form of POSIX path of SomeItem user name "me" password "mypassword" with administrator privileges
    end if
    return
    end ProcessStuff
    </pre>
    You shouldn't need to change the ownership, so I commented out the chown shell script since this would need to be run as a super user. You can run a shell script with administrator privileges, but in order to be used by a standard user you will need to provide the appropriate user name and password in the script, which might not be a good idea - note that the folder action script will need to be attached in all accounts that you want to change the permissions, which means that it would need to be accessible to those accounts.

Maybe you are looking for

  • Operating System detection of client

    hi , I stuck with one problem? I want to detect user/client Operating System? can anybody tell me how to do it? thanks

  • Error in Creating Database - An unexpected error has been detected by HotSp

    I just installed Oracle 11 g on Vista. I tried to create a database and received the following error. # An unexpected error has been detected by HotSpot Virtual Machine: # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x773a59c3, pid=7624, tid=8164 #

  • Creating a variant transaction

    Hi, Im trying to create the above in SE93. Im calling it Z_SWWL and its calling transaction SWWL, which contains variants. But its not finding any 'transaction variant' to choose from!? Any ideas? Thanks, Dave

  • Tcode-SQVI

    Dear All, I am Getting ABAP Runtime error while creating table join using t-code SQVI . When i Go to SQVI - - - then Quick View ZABC - - -Insert Table - - -Add Table EKKO Its giving me run time error Could you please hepl me find out any OSS Notes av

  • How to call the backing bean method through javascript

    Hi I have a command button associated with actionListener . Action Listener method associated with backing bean methods. I want to fire the event on command button and backing bean method should be invoked from javascript dynamically. can anybody hel