Scope of GlobalRef

I was wondering what the scope of a Global reference to an object in JNI. I have read two different references and they seemed to contradict each other.
In the example below would jmanager be visible outside this JNI function??
static jobject jmanager;
JNIEXPORT void JNICALL Java_stuff(JNIEnv *env, jobject obj, jobject jmanager) {
if (jmanager == 0) {
    jclass jlocalRef = env->GetObjectClass(manager)     ;
    if (jlocalRef == 0 ) {
         return -5; //Could not get object.
    }//end if
  jmanager= env->NewGlobalRef(jlocalRef);
  if (jmanager == NULL) {
        return -1; //out of memory;
  }//end if
  }//end if
return 1;
JNIEXPORT void JNICALL Java_useStuff(JNIEnv *env, jobject obj) {
   //Initialize Java object
//**WILL THIS WORK jmanager
  jclass cls = env->GetObjectClass(jmanager);
  //Get and call setNumPoints (JAVA)
  jmethodID mid = env->GetMethodID(cls, "setNumPoints", "(I)V");
  if (mid == NULL) {
     printf("Could not find setNumPoints method");
                     return -1;
   }//end if
   env->CallVoidMethod(routeMgr, mid, pntCount);

Have you tried it out? That code looks ready to run.
Not sure what you mean by "scope" and "visible". In C/C++ language terms, yes that static variable will be in scope and visible from both functions, assuming all are in the same translation unit (file). There's nothing specific to JNI about that.
Of if you are really asking "what is the lifespan of the Java object associated with the jmanager reference variable, after creating the reference via NewGlobalRef?" then the answer is that the object remains alive and ineligible for garbage collection until you later call DeleteGlobalRef on the reference. Hopefully you don't have any documentation indicating otherwise -- it's kinda important!
-slj-

Similar Messages

  • What deterimes the amount of data in a waveform from a TDS 1012 scope

    Hello,
       What determines the amount of data that is in a waveform that comes out of a TDS 1012 scope? I am assuming that I will have to look at the driver vi to determine the commands sent to the scope to figure it out. I am in a situation that I need to have the y axis to have a high resolution, that results in very little data being collected from the scope.
    Regards,
    Kaspar
    Regards,
    Kaspar

    Hello,
        The amount of data that comes out of the TDS 1012 scope is determined by the data start (DATaTARt)  and data stop (DATaTOP)  commands that are defined on page 58 (2-38) in the  346 page programming manual for the scope. I found of that the data start was not set to 1, which is the beginning of the data.
        I also had a very low level signal on channel that was all most unreadable by the scope that caused me to think that I was not getting all of the data.
    Regards,
    Kaspar
    Regards,
    Kaspar

  • Accessing message out of scope

    Hi all,
    I have a message "Message_A" constructed inside the scope shape and being sent to the send port. Now when any exception occurs i need to log the details to the database. I have an exception handler with the expression in the construct message as
    below
    Excep_message(FILE.ReceivedFileName)=Message_A(FILE.ReceivedFileName);
    I received the error "use of unconstructed message 'Message_A'" when compiling the project. For this error i constructed the message "Message_A" before the scope shape as below.
    Message_A=null;
    Message_A(BTS.Operation)="Operation";
    Then i was able to compile the project without any error. When i deployed and the application exectued i got the below error.
    xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Ibox.UNEDIFACT.COPARN.Orchestration.CoparnOrchestration_AEJEA(3f2f8342-08cd-6b69-c647-d13dc48b24ad)'.
    The service instance will remain suspended until administratively resumed or terminated.
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: 5bbb4a82-19ae-48bc-8bc0-b8c992088c68
    Shape name: ConstructMessage_1
    ShapeId: a849f763-3f7f-4bc3-bea2-9887fc3c7415
    Exception thrown from: segment 1, progress 10
    Inner exception: The part 'part' of message 'Message_A' contained a null value at the end of the construct block.
    Exception type: NullPartException
    Source: Microsoft.XLANGs.Engine
    Target Site: Void ConstructionCompleteEvent(Boolean)
    The following is a stack trace that identifies the location where the exception occured
       at Microsoft.XLANGs.Core.Part.ConstructionCompleteEvent(Boolean fKillUnderlyingPart)
       at Microsoft.XLANGs.Core.XMessage.ConstructionCompleteEvent(Boolean killUnderlyingPartWhenDirty)
       at Ibox.UNEDIFACT.COPARN.Orchestration.CoparnOrchestration_AEJEA.segment1(StopConditions stopOn)
       at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
    Kindly assist why the null error is being raised even when i have assigned the Message_A with a value.
    Regards, Vivin.

    You assigned Message_A with a null value, that's where the null error is raised! 
    To assign Message_A with a value you will need to execute a mapping or assign it with a variable that contains a xmlDocument if your Message_A is a generic message.
    Another question: why do you want a null Message_A on your messagebox? Is that the required behavior?
    Be sure to also check following blog by Paole, it contains everything you need to know about processing and creating xlangmessages:
    http://blogs.msdn.com/b/appfabriccat/archive/2010/06/23/4-different-ways-to-process-an-xlangmessage-within-an-helper-component-invoked-by-an-orchestration.aspx
    Glenn Colpaert - Microsoft Integration MVP - Blog : http://blog.codit.eu

  • What is the scope of implicit loop variables?

    Hi,
    I'm facing some strange error from the ABSL editor (syntax checker).
    In ABSL the loop variables are implicit and don't have to be declared in the head section of the script.
    My question now is simple: How is the scope/visibility of such loop variables specified ?
    There's a complete code snippet below.
    In line no.9, there's the first time use of implicit loop variable 'task_inst'.
    Because of type inference, it will be typed as MasterDataWanneBe/Tasks (which is my own BO type).
    In line no.20, I want to use the same variable name in a different loop, outside the parenthesis/scope of the first first use.
    Now the ABSL syntax checker complains about incompatible types (see code snippet)
    Thus the type inference should result in the, (lets say 'local') type Project/Task, which is the one I was querying for.
    To me it looks like, that loop variables implicitly get a global scope (hopefully bound to this ABSL file only).
    I would like to see the scope/visibility of loop variables restricted to the parenthesis.
    In other words only inside the loop.
    Hint
    I heard (from little sparrows), that local variable scoping is not possible because of underlying
    generated ABAP code. If so, than it would be helpful to print warnings, in case of types are compatible
    but used in different scopes. Think about the unintended side effects.
    import ABSL;
    import AP.ProjectManagement.Global;
    var query_tasks;
    var query_tasks_param;
    var query_tasks_result;
    foreach (empl_inst in this.Employees) {
         foreach (task_inst in empl_inst.Tasks) {
             //   ^^^^^^^^^  first time use
              task_inst.Delete();
    // ===========================================================================
    query_tasks = Project.Task.QueryByResponsibleEmployee;
    query_tasks_param = query_tasks.CreateSelectionParams();
    query_tasks_result = query_tasks.Execute(query_tasks_param);
    foreach (task_inst in query_tasks_result) {
          // ^^^^^^^^^ Error: 4
          // The foreach loop variable is already inferred to an incompatible type:
          // Node(MasterDataWanneBe/Tasks). Expected Node(Project/Task)

    Yes, variable declarations in ByD Scripting Language indeed have (snippet) global visibility. In the FP 3.0 release the variables can be declared anywhere in the snippet (not only in the beginning, as with FP 2.6), however still not within code blocks, i.e. within curly braces ({}). Therefore variable name shadowing is still not supported and because of the global visibility of variables they cannot be reused for a different type, later in the same snippet. This is because of the statically typed nature of ByD Script, despite the type inference convenience.
    Kind regards,
    Andreas Mueller

  • How to get a parameter from each request in a session scope BackingBean

    While calling my JSF page, I pass an id as parameter in the URL, and in the Backing bean I retrieve it from the request.
    On each request I need to get the id and populate the page accordingly.
    But I am forced to create my Backing Bean in session scope b'cos otherwise ValueChangeListener method does not work properly.
    So where and how do I get the id on each request?
    Pls. help

    What you can do is create it in the request scope like this:
    <managed-bean>
          <managed-bean-name>personBean</managed-bean-name>
          <managed-bean-class>
            com.PersonBean
          </managed-bean-class>
          <managed-bean-scope>request</managed-bean-scope>
           <managed-property>
                 <property-name>id</property-name>
                 <property-class>java.lang.Long</property-class>
              <value>#{param.id}</value>
          </managed-property>
    </managed-bean>And then in the page use a hidden field to set the id in case of a postback (validation error):
    <h:inputHidden id="id" value="#{personBean.id}"/>Does that help you?
    Thomas

  • Getting bean from request scope

    Hi,
    I am new to JSF and unfortunately I am running into a problem that I am not entirely sure about. I look in other forums and what I am doing looks right but I am not getting the desired result.
    In my faces-config.xml file I have a managed bean defined as follows:
    <managed-bean>
        <managed-bean-name>LogIn</managed-bean-name>
        <managed-bean-class>lex.cac.tables.RefUsers</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>I then have a log on page with a form which contains a user name and password field. The tags are defined as
    <h:inputText immediate="false" value="#{LogIn.username}" /> (for username) and
    <h:inputSecret immediate="false" required="true"
                                   value="#{LogIn.password}" /> (for password)
    When I submit the form the web app navigates to a jsp page which attempts to do validation against a database.
    The first step though is retrieving the object which is suppose to be in request scope.
    I attempt the following but I get back null which causes a NullPointerException. Why can't if find the bean?
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    Map params         = ec.getRequestParameterMap();
    params.get("LogIn");  //null is returned hereWhat am i doing wrong? Can someone please help.
    Thanks in advance,
    Alex.

    Something like that:
    FacesContext fc = FacesContext.getCurrentInstance();
    RefUsers LogIn = (RefUsers)fc.getApplication().createValueBinding("#{LogIn}").getValue(fc);
    String username = LogIn.getUsername();
    String password = LogIn.getPassword();

  • Session scope managed bean is not instantiating?

    We have the need to use a session bean (rather than pageFlowScope) in our application.  But it looks like the session beans are not being instantiated at run time like other beans are.  I created a simple test case to verify.  One bean, named "MySessionBean", defined in the task flow as Session scope, then referenced in a view with an input text box, value:  #{sessionScope.MySessionBean.value1}. When I run the application,  I just get PropertyNotFoundException, Target Unreachable, 'MySessionBean' returned null.
    If I simply change the bean to use pageFlowScope, everything works fine.   I have debug code in the bean constructor, and it never gets called.   Is there some other step I am missing to have ADF instantiate the session bean?

    No luck, I tried it in both adfc-config.xml, and faces-config.xml.  I also tried moving the call to my view, from my bounded taskflow, into the adfc-config unbounded task flow, and then I ran that instead.  Still got the same error.    Here is my code from the the last round of tests with the view called in the main adfc-config.xml unbounded taskflow:
    adfc-config.xml:
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
          <view id="testView">
                <page>/testView.jspx</page>
          </view>
          <managed-bean id="__2">
          <managed-bean-name id="__5">MySessionBean</managed-bean-name>
          <managed-bean-class id="__4">test.MySessionBean</managed-bean-class>
          <managed-bean-scope id="__3">session</managed-bean-scope>
        </managed-bean>
    </adfc-config>
    testView.jspx:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=UTF-8"/>
      <f:view>
        <af:document id="d1">
          <af:form id="f1">
            <af:inputText label="Label 1" id="it1"
                          value="#{sessionScope.MySessionBean.value1}"/>
          </af:form>
        </af:document>
      </f:view>
    </jsp:root>
    MySessionBean.java:
    package test;
    public class MySessionBean {
        private String value1="Hello World";
        public MySessionBean() {
            super();
        public void setValue1(String value1) {
            this.value1 = value1;
        public String getValue1() {
            return value1;

  • ASA Migration of DHCP Scope to a Server

    Hello All,
    We migrated the DHCP scope from the ASA to a MS DHCP server with this configuration:
    group-policy BV-SSL1 internal
    group-policy BV-SSL1 attributes
    no address-pools value remotepool4 remotepool2 remotepool3
    no intercept-dhcp enable
    dhcp-network-scope 10.180.49.0
    exit
    tunnel-group BVVPN10 general-attributes
    no address-pool remotepool2
    no address-pool remotepool3
    no address-pool remotepool4
    dhcp-server 10.182.14.55
    exit
    tunnel-group BV-SSL general-attributes
    no address-pool remotepool2
    no address-pool remotepool3
    no address-pool remotepool4
    dhcp-server 10.182.14.55
    exit
    no vpn-addr-assign aaa
    no vpn-addr-assign local
    vpn-addr-assign dhcp
    This is running good, until we used all 254 addresses that was specified in the dhcp-network-scope.
    My question is should i have specified dhcp-network-scope none to allow for all 3 scopes can be used to hand out IP addresses for the remote users?
    Thanks,
    Kimberly

    Okay, that's at least a good start. Can you monitor the ULS logs while you attempt to browse to the site to see what form of error(s) you're getting?
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Problem with scope in DESTINATION_APP

    Experts --
    I am using a Default logic file to move data from FINANCEDETAIL cube to FINANCE.
    *DESTINATION_APP=FINANCE
    *SKIP_DIM=LINEITEMDETAIL
    *WHEN Entity
    *IS *
    *REC(EXPRESSION=%Value%)
    *ENDWHEN
    *COMMIT
    My problem is with the logic's scope.  When I post to FINANCEDETAIL for JAN it posts to FINANCE only for JAN.  That is normally correct, but in this case I want it to post from detail to ALL months within the year--even if FINANCEDETAIL has not changed.
    I have added XDIM_MEMBERSET TIME=%MyTime% (i.e. all months).
    I added a line to the logic *DESTINATION TIME=%MyTime%
    I can tell from DebugLogic.log that all of the months are part of my original query.  Records to be posted, however, are only months that have actually changed.
    Documentation suggests that I need to put this logic within a *RUNLOGIC?  Is that the right track?
    Thanks...Marv

    Hi Halomoan--
    Thanks for responding.  I am using BPC version 5.1.
    Here is my logic in all it's gory detail.
    BPC is actually working as it is supposed to.  It is sending back data from DETAIL that has changed.
    I want it to send back ALL the time series monthly data for selected Account/Entity--even though it appears it has not changed in DETAIL (I have a problem in that FINANCE may be out of synch with FINANCEDETAIL).
    *CALCULATE_DIFFERENCE 0
    *MEMBERSET(%MyDetail%,"Descendants([DETAIL].[AllLineItems],999,leaves)")
    *XDIM_MEMBERSET DETAIL=AllLineItems,%MyDetail%
    *MEMBERSET(%MyTime%,"Descendants([TIME].[2009.Total],999,leaves)")
    *XDIM_MEMBERSET TIME=%MyTime%
    *DESTINATION_APP=FINANCE
    *DESTINATION TIME=%MyTime%
    *SKIPDIM=DETAIL
    *RENAME_DIM DATASOURCE=DATASRC
    *ADD_DIM DATATYPE=AVG
    *ADD_DIM INTCO=NON_INTERCO
    *WHEN DEPARTMENT
    *IS *
         *REC(EXPRESSION=%VALUE%)
    *ENDWHEN
    *COMMIT

  • Problem with beans in session scope

    Hello,
    I developped a website using JSP/Tomcat and I can't figure out how to fix this problem.
    I am using beans in session scope to know when a user is actualy logged in or not and to make some basic informations about him avaible to the pages. I then add those beans to an application scope bean that manages the users, letting me know how many are logged in, etc... I store the user beans in a Vector list.
    The problem is that the session beans never seem to be destroyed. I made a logout page which use <jsp:remove/> but all it does is to remove the bean from the scope and not actualy destroying it. I have to notify the application bean that the session is terminated so I manualy remove it from its vector list.
    But when a user just leave the site without using the logout option, it becomes a problem. Is there a way to actualy tell when a session bean is being destroyed ? I tried to check with my application bean if there are null beans in the list but it never happens, the user bean always stays in memory.
    Is there actualy a way for me to notify the application bean when the user quits the website without using the logout link ? Or is the whole design flawed ?
    Thanks in advance.
    Nicolas Jaccard

    I understand I could create a listener even with my current setup Correct, you configure listeners in web.xml and they are applicable to a whole web application irrespective of whether you use jsp or servlets or both. SessionListeners would fire when a session was created or when a session is about to be dropped.
    but I do not know how I could get a reference of the application bean in >question. Any hint ?From your earlier post, I understand that you add a UserBean to a session and then the UserBean to a vector stoed in application scope.
    Something like below,
    UserBean user = new UserBean();
    //set  bean in session scope.
    session.setAttribute("user", user);
    //add bean to a Vector stored in application scope.
    Vector v = (Vector)(getServletContext().getAttribute("userList"));
    v.add(user);If you have done it in the above fashion, you realize, dont you, that its the same object that's added to both the session and to the vector stored in application scope.
    So in your sessionDestroyed() method of your HttpSessionListener implementation,
    void sessionDestroyed(HttpSessionEvent event){
         //get a handle to the session
         HttpSession session = event.getSession();
          //get a handle to the user object
          UserBean user = (UserBean)session.getAttribute("user");
           //get a handle to the application object
          ServletContext ctx = session.getServletContext();
           //get a handle to the Vector storing the user objs in application scope
            Vector v = (Vector)ctx.getAttribute("userList");
           //now remove the object from the Vector passing in the reference to the object retrieved from the Session.
            v.removeElement(user);
    }That's it.
    Another approach would be to remove the User based on a unique identifier. Let's assume each User has a unique id (If your User has no such feature, you could still add one and set the user id to the session id that the user is associated with)
    void sessionDestroyed(HttpSessionEvent event){
         //get a handle to the session
         HttpSession session = event.getSession();
          //get a handle to the user object
          UserBean user = (UserBean)session.getAttribute("user");
           //get the unique id of the user object
           String id = user.getId();
           //get a handle to the application object
          ServletContext ctx = session.getServletContext();
           //get a handle to the Vector storing the user objs in application scope
            Vector v = (Vector)ctx.getAttribute("userList");
           //now iterate all user objects in the Vector
           for(Iterator itr = v.iterator(); itr.hasNext()) {
                   User user = (User)itr.next();               
                    if(user.getId().equals(id)) {
                           //if user's id is same as id of user retrieved from session
                           //remove the object
                           itr.remove();
    }Hope that helps,
    ram.

  • Define Scope list and additional fields in ALV report

    Dear Network Members.
    My client want to enhance the screen for releasing the PR. He needs ALV GRID report. The report should contain following fields
    Document Type: Quantity Requested: Purchase Requisition: Delivery Date: Item of Requisition Material Group: Acct Assignment Cat.:,Plant:  Requisitor;Purchasing Group: Short Text:;Stocks Fields,Own Stock,Consignment Stock,Project Stock,Total Stock, Unrestricted,use,Reserved,Blocked,Qual. Inspection,Total Stock.
    I have created ZALV in Define scope of list also defaulted to transaction ME5A.
    Pls. let me know how I can bring Stocks Fields" Own Stock,Consignment Stock,Project Stock,Total Stock, Unrestricted,use,Reserved,Blocked,Qual. Inspection,Total Stock." in the report.          
    Will appreciate your help.
    Regards,
    Vijay Mundke

    Hi,
    You can obtain these fields from MMBE. or you can run a Querry in SQ01/SQ02 to pull records from SAP infostructures.

  • Sales orders in TDMS company/time based reduction  are outside the scope

    Guys,
    I have had some issues with TDMS wheras it didn't handle company codes without plants very well. That was fixed by SAP. But I have another problem now. If I do a company code and time based reduction, It doesn't seem to affect my sales orders in VBAK/VBUK as I would have expected. I was hoping it would only copy sales orders across that have a plant which is assigned to a company code that was specified in the company code based reduction scenario. That doesn't seem to be the case.
    VBAK is now about one third of the size of the original table (number of records). But I see no logic behind the reduction. I can clearly see plenty of sales documents that have a time stamp way back from what I specified in my copy procedure and I can see others that have plant entries that should have been excluded from the copy as they do belong to different company codes than the ones I specified.
    I was under the impression that TDMS would sort out the correct sales orders for me but somehow that doesn't seem to be happening. I have to investigate further as to what exactly it did bring across but just by looking at what's in the target system I can see plenty of "wrong" entries in there either with a date outside the scope or with a plant outside the scope.
    I can also see that at least the first 10'000 entries in VBAK in the target system have a valid from and to date of 00.00.0000 which could explain why the time based reduction didn't work?
    Did you have similar experiences with your copies? Do I have to do a more detailed reduction such as specifying tables/fields and values?
    Thanks for any suggestions
    Stefan
    Edited by: Stefan Sinzig on Oct 3, 2011 4:57 AM

    The reduction itself is not based on the date when the order was created but the logic enhances it to invoices and offers, basically the complete update process.
    If you see data that definitely shouldn't be there I'd open an OSS call and let the support check what's wrong.
    Markus

  • Background job getting cancelled : Choose at least one scope of list

    Hello to all,
    I am trying to Run on Z report in background which conatins SUBMIT statement to standard progarm for MB5B .This report already programmed to call a report in background.It takes stocks for given period,I am taking the values using "import memory-id" statement.It gives an error log in SM37 as:
    Choose at least one scope of list
    Message no. M7829
    Can we call a submit stmt in a report that is to run in background?? or pls provide any alternative for this problem??
    Thnax & Regards
    Sonal

    Hi Sonal,
    1. This is happening because there are some checkboxes on the selection screen
       which are ticked by default when we run in fore ground
       and are blank when run in  background.
      Hence the system gives the error meaning to select atleast one of them.
    2. We can simulate this error in foreground also.
       There is one button on selection screen in the middle frame.
       "> Category"
       Just push it.
       Some checkboxes will appear now.
       Untick all of them and run the report. You will get the same error
    Choose at least one scope of list
    3. So while doing SUBMIT in the z report, you can pass the values of those checkboxes (which ever you require) as 'X'.
    eg.
    report abc.
    submit RM07MLBD
    with matnr = '3'
    with pa_wdzer = 'X'.
    4. The checkboxes field names are:
    PARAMETERS : pa_wdzer    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_wdzew    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_wdwiz    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_wdwuw    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_wdwew    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_ndzer    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    PARAMETERS : pa_ndsto    LIKE AM07M-MB5B_XONUL
                              modif id liu.
    regards,
    amit m.

  • How to use a JavaBean with request scope from one page to other page

    Hi,
    I want to use in one jsp file a javabean with scope of request for it, I use:
       <jsp:useBean id="entry" class="jsps.SaleEntry" scope="request" />and after in that page I make operations with it using the jsp:setProperty and jsp:getProperty operations
    My question is that if I want to get the result of that javabean in the following page, Have I to record the javabean doing : request.setAttribute(""objectId",id) and then in the following jsp page I can rescue the object doing: SaleEntry sE=(SaleEntry) request.getAttribute("objectId") ???
    or in the contrary, only using jsp:setProperty the information is available to recover it in the following jsp doing : SaleEntry sE=(SaleEntry) request.getAttribute("objectId") because setProperty records the information without need of doing : request.setAttribute(""objectId",id). ????
    Thanks with anticipation and sorry if it is a silly question but I am beginner in the use of JavaBeans

    Thanks Anthony,
    I'm working with Tigi on the same project and now I can tell you that the problem is solved.
    request.getRequestDisptacher("/myServlet");hehe, you switched the 't' and the 'a'
    <%@ include file="/myServlet" %>this is the one we use :)
    But what is the difference between the first one and the last one? Now We are using the last one because that's the shortest :) not a pretty good reason huh :)
    cheers,
    Soep

  • How to use "scope " attrubute in useBean tag

    Can anyone please tell me if I can use the same JavaBean Class to hold information form different pages? well, let me explain exactely what I want to do:
    I have a Java bean Class that holds a property 'Name':
    package ContactManager;
    public class Person {
    private String name="%";
    public String getName () {
    return this.name;
    public void setName (String my_name) {
    name = my_name + "%" ;
    I'm using this class to store temporarly the Criteria of search from a JSP/HTML page to send to a database for search and for UPDATE -> this of course is done in different HTML/JSP pages. The problem I have is that the first time I set the properties (when the user make a search) this value remains unchanged [-> the second time when the user asks for update, I try to use the same bean to keep the value => unfortuntly it returns me the old value]
    My question is: is the use of 'scope' attribute of the "jsp:useBean" tag can solve this problem? if yes how to use it? I've tryed to set the scope of the bean to page but that does not help :-(
    Pleaze help, I'm stuck.... Bellow is the 4 JSP pages for:
    - person_search.jsp / person_result.jsp
    - request_modify.jsp/ DoModify.jsp
    1 -person_search.jsp
    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD><TITLE>Person Search</TITLE></HEAD>
    <BODY><CENTER>
    <form method="POST" action="person_result.jsp">
    Name <input type="text" name="name" size="47"></p>
    <input type="submit" value="Submit" name="B1">
    <input type="reset" value="Reset" name="B2"></p>
    </form></body>
    </html>
    2- person_result.jsp
    <%@ page import="java.sql.*" %>
    <HTML><BODY>
    <jsp:useBean id="theBean" class="ContactManager.Person"/>
    <jsp:setProperty name="theBean" property="*" />
    Name<BR>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    Statement s = con.createStatement();
    String sql = "SELECT Client.ClientID, Client.Name FROM Client where Client.Name like " + "'" + theBean.getName() + "'";
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    String myId = rs.getString(1);
    %>
    <TR>
    <TD><%= myId %></TD>
    <TD><a href="person_detail.jsp?id=<%= myId %>"><%=rs.getString(2)%></a></TD>
    <TD><a href="delete_person.jsp?id=<%= myId %>">Delete</a></TD><BR>
    </TR>
    <%
    rs.close();
    s.close();
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    System.out.println(e.toString());
    %>
    </BODY>
    </HTML>
    3- request_modify.jsp
    <%@ page import="java.sql.*" %>
    <html>
    <head><title>AddressBook: Modifying Person <%= request.getParameter ("id") %></title> </head>
    <body bgcolor="#ffffee">
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    int rowsAffected = 0;
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    Statement s = con.createStatement();
    String sql = "SELECT Client.ClientID, Client.Name FROM Client where ClientID ="+ request.getParameter("id");
    ResultSet rs = s.executeQuery(sql);
    if (rs.next()) {
    %>
    Client Name is <input type=text name=name value=<%= rs.getString(2) %>> <br>
    <TD><a href="person_do_modify.jsp?id=<%= rs.getString(1)%>">Confirm Modify</a></TD>
    <%
    rs.close();
    s.close();
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    System.out.println(e.toString());
    %>
    </BODY> </HTML>
    4- do_modify.jsp
    <%@ page import="java.sql.*" %>
    <html>
    <head><title>AddressBook: Modifying Address <%= request.getParameter ("id") %></title></head>
    <body bgcolor="#ffffee">
    <jsp:useBean id="theBean" class="ContactManager.Person" scope="page"/>
    <jsp:setProperty name="theBean" property="name"/>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("JDBC driver loaded");
    catch (ClassNotFoundException e) {
    System.out.println(e.toString());
    %>
    <%
    int rowsAffected = 0;
    try {
    Connection con = DriverManager.getConnection("jdbc:odbc:ContactManager");
    PreparedStatement preparedStatement = con.prepareStatement ("UPDATE Client SET Name=? WHERE ClientID =?");
    preparedStatement.setString (1, theBean.getName());
    preparedStatement.setString (2, request.getParameter("id"));
    rowsAffected = preparedStatement.executeUpdate ();
    preparedStatement.close ();
    if (rowsAffected == 1) {
    %>
    done
    <%
    else{
    %>
    Not Modified
    <%
    con.close();
    catch (SQLException e) {
    System.out.println(e.toString());
    catch (Exception e) {
    %>
    </BODY></HTML>
    Thank you for the help.
    Sammy

    While a quick search on the <jsp:useBean> tag and the scope attribute will probably yield more information than I can summarize in a few sentences, I'm pretty sure that using the scope="page" attribute on a bean will cause that bean to be instantiated every time the page is loaded. In order for a bean to persist longer than the existance of that page (whether you're loading a new page, or reloading the same one), you'd need to set the scope to session or application (you'd probably want session).

Maybe you are looking for

  • Amount field with dollar symbol?

    Hello I have a AMOUNT field on my_form. Because of good compatibility/data transfer i have defined it as a DECIMAL FIELD 12,3. Data transfer is btwn my_form and back end system SAP / Oracle. Fine. But, user want to have the below requirement: Say, fo

  • Installing Windows 2003 Server Standard/XP is very slow- how long does it take?

    Hello, I'm looking for some ideas here...  I tried installing Windows 2003 on my newly build computer, but after 3 hours it still wasn't installed, and seemed to just be really really slow, and not frozen.  I ended up giving up and tried putting wind

  • Fit Image

    Hello, I created an empty frame with 120mm width. Then I placed an image into it using "Paste Into". I would like the image to have 112mm width (4mm margin to frame at each side) and scale proporcionally. And I want the frame to also get a 4mm margin

  • What editor do you use?

    I'm just curious as to what editors people use to edit their java programs on Windows...

  • Negative values should not be allowed for fields

    Hello Gurus, I have a table and right now the feilds f1 and f2 are allowing negative values to be stored as they are of type char4, now that i dont want those feilds to allow negative values. i am using these feilds in the feild catalog in the ALV as