How to call a method in one JSP from another JSP?

say that I have 2 JSPs.
JSP one has a button.
JSP two has some method that, say, find the square root of the number passed from JPS one.
How to - when click - the button on page one call the method on page two?
Please note that I can not use object binding, but I want passing the actual parameter and call the method on page two.
Please note that this is an update of a previous post on the same topic called "Object scope".
Thank you all very much.

No, i dont know how to call other than main methods from other classes
And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

Similar Messages

  • How to call main method in one class from another class

    Suppose i have a code like this
    class Demo
    public static void main(String args[])
    System.out.println("We are in First class");
    class Demo1
    public static void main(String args[])
    System.out.println("We are in second class");
    In the above program how to call main method in demo calss from Demo1 class......???????

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • Calling a method of one class from another withing the same package

    hi,
    i've some problem in calling a method of one class from another class within the same package.
    for eg. if in Package mypack. i'm having 2 files, f1 and f2. i would like to call a method of f2 from f1(f1 is a servlet) . i donno exactly how to instantiate the object for f2. can anybody please help me in this regard.
    Thank u in advance.
    Regards,
    Fazli

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Need call a method of one iview from another iview

    Hi,
    There are 2 iviews in a component.
    1) FirstView - contains abc() method & xyz() methods
    2) SecondView (a popup) - asdf() method
    i want to call abc() method from asdf() method. i.e. i want to call a method of the firstview from the secondview.
    Note:
    1) i couldn't able to copy the code of abc() method to component controller, as it has the code which uses (iview) local attributes (this can be done by context mapping) & main reason is from the method it calls the xyz() method of the same view (again i couldn't call a method of iview from component controller).
    2) firstView contain 5 tabs, i want to be in the same tab from which secondview (popup) was called, if i use fire plugs between both view, the current tab will be chnaged (i suppose, not sure).
    3) can we use event handlers, if yes how can we do that.
    Please provide a better solution for calling a method of view from another view.
    Thanks
    Maha
    Edited by: Maha Hussain on Jan 13, 2009 12:40 PM

    Hi Maha,
    It is better to have such methods in the component controller to make it reusable and avoid writing same code again and again.
    You can have that method in component controller and call that method on click on a button from Iview1 and can pass the parameters in the mthgod only.
    for example.
    Say Method abc() which is currently in Iview1 and you are passing values from context say aa bb cc to the method now what i am suggesting is
    have that method abc(String aa, String bb, String cc) ;
    and call it on click on button in Iview1 and pass the required parameters.
    Hope this will help
    Regards
    Narendra

  • How to call a method of one dc in another dc

    Hi,
          i have two dcs dc1 and dc2
    i want to call the method of dc1 interface controller in component controller of dc2
    plz help me, how to acheive it
    Thanks & regards,
    v santhosh

    Hi Vanama,
    Hope you have defined a method say method1() in interface controller of DC1
    Add this to public part.
    In DC2 , set DC1 as used DC.
    give <DCUsageName>
    now you can access the method in DC1 like this.
    wdThis.wdGet<DCUsageName>().getmethod1();
    Regards,
    Murtuza

  • How to call the task flow  one region from another region?

    I have page with 3 regions (column wise) named as start, center, end.
    currently I having task flow for middle(i.e, center) region which have panelCollection to perform view, create, & delete functions.
    Task flow:-
    From(action)To
    View(create)Create
    Create(Done)Execute (Execute is a method call)
    Execute(*)View
    View(self)Execute
    By press create button on Center page, task flow takes to the Create page(in Centre region) but all other regions(start, end) remains same.
    I have a usecase where we have a commandLink on Start region to show the View page on Center region. but it is not able to achieve when we move to Create/Edit page.
    Plz help me out to built the same.
    Thanq
    KSB
    Edited by: user641407 on Aug 28, 2008 2:22 PM
    Edited by: user641407 on Aug 28, 2008 2:23 PM

    Hi!
    First, I'm not sure that your page layout is adequate. The regions are not intended to be navigated from outside. Yet, they can send navigation action to the container (page on which the region is placed) through Parent Action taskflow element. Also, you can investigate Contextual Events that can be raised by region, but I'm also not sure that this can be easily used for cross-region navigation.
    I would suggest you to reconsider you page layout. You can use dynamic regions (which are populated by taskflow based on menu selection or click on actionLink or s button). This way, in the Start facet you place a navigation menu (links), which are connected with dynamic region in Center. If you want to reuse a navigation links (in Start), you can put all this in page template and reuse it over and over again.
    Regards,
    PaKo

  • How to call a method of a class from another class

    Hi,
    Can some one explain me this? I want the label from the Label class to be displayed in the JFrame. I understand to do this, I have to call "label" to the ABC() and createAndShowGUI().
    I am novice. It will be really helpful if you could explain me what you did.
    class Label {
      public Label() {
      public JTextField label;
      label = new JTextField("Hi");
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FrameDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel emptyLabel = new JLabel("");
            emptyLabel.setPreferredSize(new Dimension(600, 400));
            frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
        }Will it be some thing like this?
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
                    Label label = new Label();
                    label.add
    private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FrameDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel emptyLabel = new JLabel("");
            emptyLabel.setPreferredSize(new Dimension(600, 400));
            frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
           frame.add(new Label());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }

    merit wrote:
    Hi,
    Can some one explain me this? I want the label from the Label class to be displayed in the JFrame. I understand to do this, I have to call "label" to the ABC() and createAndShowGUI().
    I am novice. It will be really helpful if you could explain me what you did.
    class Label {
    public Label() {
    public JTextField label;
    label = new JTextField("Hi");
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("FrameDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    }Will it be some thing like this?
    public ABC() {    //Constructor
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
    Label label = new Label();
    label.add
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("FrameDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    frame.add(new Label());
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    You know it maybe that it's just too late at night for me, but I see you complete Label class, but I don't see a class definition for ABC; you have a constructor for it, but not a class definition for it.
    In any case, when you define a class, you use it in the same way any other class is used...
    MyClass myObjectRef = new MyClass();

  • How to call  a method of one view in other view

    Hi
      could any one suggest "how to call  a method of one view in other view "
    thanks
    kaushik

    Hi Kausic,
    Its not possible to call a method from view to View.
    Since view is private entity we can not pass the data directly.
    I suggest you to declare the method in Component/Custom controller and call.
    the code is,
    wdThis.wdGet<Component/Custom Name>Controller().<methodName>();
    Regards,
    <b>Ramganesan K</b>

  • Can I Call method on one JVM from another through a dll?

    Let me explain.
    I have this java jar file that I can only have one instance of running at any given time. I'm using a shared data segment in a dll to store a bool indicating whether the program is already running or not. If it's already running, I have to not run the second instance and give focus to the current running instance.
    The jar file calls a native method "canInstantiate()" on a dll to see if there's already an app running. If there isn't, the env and obj are stored in the shared data segment of the dll and we return true. If there is already an instance of the program running, I want canInstantiate call a function on the current instance of the jar (like a callback) to tell it to request focus. It's not working. Can someone tell me if my code is right?
    The .h file
    #include "stdafx.h"
    #include <jni.h>
    #include "CardServer.h"
    #pragma data_seg("SHARED") // Begin the shared data segment.
    static volatile bool instanceExists = false;
    static JavaVM *theJavaVM = NULL;
    static JNIEnv* theJavaEnv= NULL;
    static jobject instanceObject = NULL;
    static jmethodID mid = NULL;
    static jclass cls = NULL;
    #pragma data_seg()
    #pragma comment(linker, "/section:SHARED,RWS")
    jdouble canInstantiate(JNIEnv *env, jobject obj);
    jdouble instantiate(JNIEnv *env, jobject obj);
    jdouble uninstantiate(JNIEnv *env, jobject obj);
    void grabFocus();
    </code>
    The .cpp file:
    <code>
    #include "MyFunctions.h"
    #include <string.h>
    #include <stdlib.h>
    #include "stdafx.h"
    #include <iostream.h>
    jdouble canInstantiate(JNIEnv *env, jobject obj)
    printf("In canInstantiate!!");
    if (!instanceExists)
    printf("No instance exists!!");
    return (jdouble)0.0;
    else
    printf("An instance already exists!!");
    grabFocus();
    return (jdouble)1.0;
    jdouble instantiate(JNIEnv *env, jobject obj)
    printf("**In CPP: Instantiate!!\n");
    cout << "At start, env is: " << env << endl;
    cout << "At start, obj is: " << obj << endl;
    if (instanceExists == false)
    instanceExists = true;
    theJavaEnv = env;
    instanceObject = obj;
    theJavaEnv->GetJavaVM(&theJavaVM);
    cls = (theJavaEnv)->FindClass("TheMainClassOfTheJar");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    printf("About to call grabFocusInJava\n");
    grabFocus();
    printf("CPP: After the grab focus command in instantiate!!\n");
    cout << "At end, env is: " << env << endl;
    cout << "At end, obj is: " << obj << endl;
    return 0.0;
    else
    printf("CPP: Finished Instantiate!!\n");
    return 1.0;
    jdouble uninstantiate(JNIEnv *env, jobject obj)
    printf("CPP: In uninstantiate!!\n");
    if (instanceExists == true)
    instanceExists = false;
    theJavaVM = NULL;
    instanceObject = NULL;
    printf("CPP: Finishing uninstantiate!!\n");
    return 0.0;
    else
    printf("CPP: Finishing uninstantiate!!\n");
    return 1.0;
    void grabFocus()
    printf("In CPP::GrabFocus!!\n");
    instanceObject = theJavaEnv->NewGlobalRef(instanceObject);
    cls = (theJavaEnv)->FindClass("CardFormatter");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    printf("Got the cls id again!!\n");
    if (cls == 0)
    printf("IT'S INVALID!!\n");
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    theJavaEnv->CallIntMethod(instanceObject, mid, 2);
    printf("Called grabFocusInJava\n");
    </code>
    thanks in advance

    Can I Call method on one JVM from another through a dll
    ...The rest of your question merely expands on your title.
    And the answer to that question is no.
    When you call a method you are executing a "thread of execution." A thread of execution exists only in a single process. It can not exist in another process.
    If the dll is doing some interesting things then you could call a method that sets a flag. Data can move between instances. But you would then have to have a thread in that different process monitoring that flag. And sharing data in a dll is not a normal process, so it would have to be coded appropriately.
    If all you want to do is set the current focus to the existing application, then that can be done with existing windows functionality. You don't need to do anything special in your dll. You can probably search these forums to find the exact code. If not there are countless examples in windows repositories (like MSDN) on how to do that.

  • How to call a method in the servlet from an applet

    I want to get the data for the applet from the servlet.
    How to call a method that exits in the servlet from the applet? I want to use http protocol to do this.
    Any suggestions? Please help.
    thanks

    Now that Web Services is around, I'd look at possibly implement a Web Service call in your applet, which can then be given back any object(s) on return. Set up your server side to handle Web Service calls. In this way, you can break the applet out into an application should you want to (with very little work) and it will still function the same

  • Is there any way to call methods of one view from another

    Hi experts,
    I am new to webdynpro.I am having some requirement in which I need to call methods of one view from some other view of same component .So is there any way to do this.

    Dear Pradeep,
    This will solve your problem......( plz 1st read everything ..)
    There are 2 views  :
    i) Mandatory Attributes ' view(V1)
    ii) Button' s  View..(V2)
    1. Create a method in Component Controller.( M1).
    2. Goto V2 . In the Action Handler method of Button , call method  M1 of component controller.
    3. Write your Code in M1 instead of  V2 method.
    4. Create an EVENT ( E1 ) in component controller.
    5. Fire this event  from M1 before executing Action Code.
    6. Now  Add the event handler method of  E1 in  V1 ( i.e. Mandatory attributes view. )   ..........clear????? .. set "METHOD TYPE" = Event Handler. instead of  Method.
    7. In this event handler method in V1 , write the "check_mandatory_attribute_view" method.
    8. use necessary flags..
    Regards ,
    Aditya.

  • How to call jsp from another jsp

    Hi, All,
    I have several jsp files in my pagelet. I need to put a link in one jsp file. When client click the link, it will show another jsp file. Could anybody tell me how to do that?  i have tried to use following code in page1.jsp,
    IPortalComponentURI componentURI= componentRequest.createPortalComponentURI();
    componentURI.setContextName("pagelet/page2.jsp");
    String docuri = componentURI.toString();
    <body>
    click  '<a href="<%=docuri %> ">here</a>' to link to pages.
    But it does not work. Any help will be great appreciated.
    Marea
    Message was edited by:
            Marea Yang
    Message was edited by:
            Marea Yang

    HI Yang,
    You can achieve it through eventhandliling in jspdynpage.
    Go through this link ,
    i.<a href="http://help.sap.com/saphelp_nw70/helpdata/en/2e/d2a441cd47a209e10000000a155106/content.htm">eventhandling</a>.
    ii.<a href="https://forums.sdn.sap.com/thread.jspa?threadID=103335">method to call jsp</a>.
    iii.<a href="https://forums.sdn.sap.com/thread.jspa?threadID=393522">calling  resource JSP in Portal Compoent</a>
    Hope It'll help you.
    Regards ,
    Malini.V

  • How to call particular method in action class from Portlets StrutsContent

    I am developing a web application which uses weblogic portlets and struts. This is what I have for now in the .portlet file.
    +<netuix:strutsContent action="getStudentList" module = "people/students"+
    refreshAction = "getStudentList" reqestAttrpersistence="none"/>
    I want it to change something like this:
    +<netuix:strutsContent action="getStudentList.do?method=allGrads" module = "people/students"+
    refreshAction = "getStudentLis.do?method=allGrads" reqestAttrpersistence="none"/>
    But this is not working. So how can I achieve something like that?
    Thanks
    Edited by: user13634949 on Jun 23, 2011 1:22 PM
    Edited by: user13634949 on Jun 23, 2011 1:22 PM

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • How to call a sp that returns multi_columns from another sp

    Hi,
    Can anybody help me to solve this problem? I called a sp which
    returns ename, sal using a weak ref cursor from another sp. Is
    it possible to do this? or I did something wrong? The error
    messages are:
    ERROR at line 1:
    ORA-00904: invalid column name
    ORA-06512: at "SCOTT.TESTPKG", line 14
    ORA-06512: at line 1
    below is my code:
    create or replace package testpkg AS           //12/19/01
    TYPE sumCur IS REF CURSOR;
    TYPE estType IS REF CURSOR;
         function totalNo (
              dno IN NUMBER)
              RETURN estType;
         procedure test(
              sum_cv IN OUT NOCOPY sumCur);
    END;
    CREATE OR REPLACE PACKAGE BODY testpkg AS
         function totalNo (
              dno IN NUMBER)
              RETURN estType IS est_cv estType;
              BEGIN
              OPEN est_cv FOR SELECT ename, sal FROM emp
    where deptno = dno and job = 'MANAGER';
              RETURN est_cv;
         END totalno;          
         procedure test(
              sum_cv IN OUT NOCOPY sumCur) AS
              sql_statement VARCHAR2(100);
         BEGIN
              sql_statement :='SELECT dname, totalNo(deptno)
    from dept ';
              OPEN sum_cv FOR sql_statement ;
         END test;     
    END;
    Thanks

    The error that you are getting is because totalNo(deptno) needs
    to be testpkg.totalNo(deptno), but that is not the only error.
    Maybe you can use something like this:
    SQL> CREATE OR REPLACE PACKAGE testpkg
      2  AS
      3    TYPE sumcur       IS         REF CURSOR;
      4    FUNCTION totalno
      5      (dno         IN            NUMBER)
      6      RETURN                     VARCHAR2;
      7    PROCEDURE test
      8      (sum_cv      IN OUT        sumcur);
      9  END testpkg;
    10  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY testpkg
      2  AS
      3    FUNCTION totalno
      4      (dno         IN            NUMBER)
      5      RETURN                     VARCHAR2
      6    IS
      7      est_cv                     VARCHAR2 (30);
      8    BEGIN
      9      SELECT ename || ' ' || TO_CHAR (sal)
    10      INTO   est_cv
    11      FROM   emp
    12      WHERE  deptno = dno
    13      AND    job = 'MANAGER';
    14      RETURN est_cv;
    15    END totalno;
    16    PROCEDURE test
    17      (sum_cv      IN OUT        sumcur)
    18    AS
    19      sql_statement              VARCHAR2 (100);
    20    BEGIN
    21      sql_statement :=
    22         ' SELECT dname, testpkg.totalno (deptno)'
    23      || ' FROM dept';
    24      OPEN sum_cv FOR sql_statement;
    25    END test;
    26  END testpkg;
    27  /
    Package body created.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXEC testpkg.test (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    DNAME
    TESTPKG.TOTALNO(DEPTNO)
    ACCOUNTING
    CLARK 2450
    RESEARCH
    JONES 2975
    SALES
    BLAKE 2850
    DNAME
    TESTPKG.TOTALNO(DEPTNO)
    OPERATIONS

  • Invoking a JSP from another JSP

    I have two JSP and both are calling different servlets. How can I call JSP B from JSP A (perhaps using a button). and how can I pass one field value from JSP B to JSP A when JSP B closes or terminate.

    Here is what I'm doing that invokes the second JSP - B
    <SCRIPT>
    function JumpToURL(url) {
              if (url != '') {
              window.location = url;
    </SCRIPT>
    <TD><INPUT type="button" name="configBtn" value="Configuration" onclick="JumpToURL('options.jsp');"><a href="/WebAppName/jsp/options.jsp"></a></TD>
    The one problem that I'm facing right now is this:
    When I start the app or JSP A (JSP that contains the code above), if the FIRST thing that I do is to click on the button above, the app call the second JSP - B, with no problem. But if start the app and click on something else that goes out to the servlet (of JSP A) and then, click on the button above I get the message: "THe pahe cannot be found" or HTTP 404 - File not found Internet Explorer.
    Can you help on this please.........Thanks..

Maybe you are looking for

  • IPad installation?

    I'm going to be getting an IPad 3 in the near future. Can I install Elements 11 onto it when I get it?

  • Quantity base POC method of result analysis

    hello all, We are trying to create the result analysis key with quantity based POC method for Projects. we are choosing the Profit basis as E,K,M but we are getting the error ' Profit basis is only used for sales order. Can anybody help resolving the

  • Abstract class methods

    I'm confused. Is this true or false. The great thing about polymorphism is that you can call one method. If the subclass inherited that method, it will be customized and perform a different duty. That way, the action it performs will depend on 1>whet

  • How to keep a playlist in sync with iPhone over iCloud

    I love being able to store all my music in the cloud with iCloud. The only problem is that I want to use iCloud to keep a selected playlist in sync with my iPhone because I only want about 500 of my 2000 songs stored on my iPhone. It is easy to do th

  • Background image moves when disabled

    I have an image in a frame window. When you click on the image and move the mouse the image moves. I have but the image still moves. Also I wish to disable the right hand mouse context menu that opens the image in a new window and other items. It doe