How can i call a servlet from a servlet ?

Hello,
Can i call a Servlet from within a Servlet ?
and is it "right thing" to Do ?
Thanks

JMO, but I wouldn't do it like this.
Don't have a remote object like a servlet doing database queries for your app. That will mean TWO network hops for every query if the database resides on another machine. The network is the biggest bottleneck you've got.
Write a JavaBean that does the database stuff for you and just have the first servlet instantiate it when it needs it. A Bean has a better chance of being reused, too. Write a TableGateway or DAO for your object.
Or write an EJB to do it.
The only time I've done a servlet-to-servlet connection like that was for one servlet running in a DMZ that would authenticate a user and then forward the request to another servlet running inside the second firewall.
I wouldn't encapsulate database query logic in a servlet like that. JMO - MOD

Similar Messages

  • How can I call an ".asp" from a Servlet?

    I want to make a call to an asp page from my servlet. If i use the conventional way of doing it as follows:
    RequestDispatcher rd = getServletContext().getRequestDispatcher("http://localhost:8080/abc.asp");
    rd.forward(request, response)
    It gives me IllegalArgumentException saying that the "Path must be absolute". And if i give the relative path like
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/abc.asp");
    rd.forward(request, response)
    In this case it takes me to the asp page, but gives some ClassNotFoundException - images.
    I do not understand what class it is looking for and where to get that?
    So Why am i not able to call an ASP from Servlet, Any clue??

    What are you trying to accomplish? A redirect is one of the only ways to successfully go from a Servlet to an ASP. For example:response.sendRedirect("http://server:9090/abc.asp?name=value");This is mainly because when you forward, your actually sending the request and response objects under the current servlet context to be processed by another JSP/servlet in the same (sometimes cross) context.
    When interacting with ASP's your actually communicating between web containers (one which is Java based the other VB based).
    When you use:RequestDispatcher rd = getServletContext().getRequestDispatcher("http://localhost:8080/abc.asp");
    rd.forward(request, response) Your telling the servlet to send it's contents outside the web container where they cannot exist as such (even though you are pointing to your own JSP server, it's the "http://" that makes it assume your trying to get out).
    Using: RequestDispatcher rd = getServletContext().getRequestDispatcher("/abc.asp");
    rd.forward(request, response) is fine but what is processing your asp in your Java Web Server?
    The best way to mix JSP/Servlets with ASP (in my opinion others may debate it if they please) is using messaging like XML. Trying to share sessions between ASP and Java is quite messy and to much effort for a 1 to 1 communication option.
    Back to an earlier question, what is processing your asp files in the Java web server? If you have something processing them (like ChilliSoft) then check the docs to see if it supports session sharing between JSP/Servlet - ASP.
    Anthony

  • How can I call a RFC from dynpage ?

    Hi!
    I would like to know how can I call a RFC from a Portal aplication, dynpage or jspdynpage. there include some libraries ?
    any idea?
    thanks

    for deploying SAP Jra :
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4#search=%22how%20to%20use%20jca%20sapjra%20site%3Asap.com%22
    For lookup of SAP Jra use:
    com.sapportals.connector.connection.IConnectionFactory connectionFactory =(IConnectionFactory) initctx.lookup( "deployedAdapters/SAPFactory/shareable/SAPFactory");
    Using SAP Jra
    http://help.sap.com/saphelp_nw04s/helpdata/en/47/13044258bdd417e10000000a1550b0/content.htm
    The important jars required are:
    connector.jar
    Genericconnector.jar
    prtjndisupport.jar
    Thanks

  • How can I call a function from a procedure

    I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
    How can I call this function from a new procedure I am creating?
    Thanks

    or refer this theread....calling function from procedure

  • How can i call a zreport from my bsp page.

    Hi friends,
    How can i call a zreport from my bsp page.
    Moosa

    Hi Friend,
    These are the codings  to be wirtten in BSP for transferring values to the REPORT
    DATA:wf_date TYPE ztable-ID.
          data:seltab type standard table of rsparams,
           wa_seltab like line of seltab,
         event TYPE REF TO if_htmlb_data.
    DATA:p_value TYPE REF TO CL_HTMLB_INPUTFIELD.
    event = cl_htmlb_manager=>get_event( runtime->server->request ).
    p_requ ?= CL_HTMLB_MANAGER=>GET_DATA(
                                            request  = runtime->server->request
                                            name     = 'inputField'
                                            id       = 'i1'
    if p_requ is not initial.
      wf_date = p_requ->value.
    endif.
    clear wa_seltab.
    if wf_date is not initial.
      wa_seltab-selname = 'P_REQU'.
      wa_seltab-kind = 'P'.
      wa_seltab-option = 'EQ'.
      wa_seltab-low = wf_date.
      append wa_seltab to seltab.
    endif.
    submit *ZSAMPLEAP1* with selection-table seltab AND RETURN  .(ZSAMPLEAP1 refers to the report name and AND RETURN for coming back to the BSP page after the completion of its operation in Report )
    IMPORT int_name TO int_name FROM MEMORY ID '*zid*'.(For importing the obtained value from Report)
    In Report
    REPORT  ZSAMPLEAP1.
    SELECT-OPTIONS: p_requ FOR ztable-id  NO INTERVALS.
    SELECT SINGLE name from ztable into int_name WHERE id = p_requ-low.
    WRITE:int_name.
        EXPORT int_name TO MEMORY  ID 'zsharmila'.
    With Regards,
    SHARMILA BRINDHA.M

  • How can we call a report from a form.

    how can we call a report from an existing form.

    Have you searched the Forms help system? It shows you how to use RUN_REPORT_OBJECT

  • How Can I call Crystal report from R3?

    Hi experts,
      How Can I call Crystal report from R3?

    Hi Bill,
    Can you please be specific and could you please provide the steps
    Thank you

  • How can I Call the MainVI from its SubVI, and this happen recursively?

    Hi All,
    How can I Call the MainVI from its SubVI, and this happen recursively?
    Actually, LAbView 7.1 doesn't support recurssion?
    Plz help me out!

    Dear GerdW,
    Thanks a lot 2 all of u guys,for all the brilliant responses.
    Actually, my basic aim is to call the Main VI, containing a SubVI.....
    Now, I want to call my main VI from this SubVI...recursively!!!!!..but whenever I tried to put the MainVI in this SubVI..an error message pops out saying recursive calling is not possible.
    I also tried using "Call by reference" but tht also didn't worked...an d error is somewat like...VI is invalid..or type matching..or state matching error.
    Here, Im attaching the snapshot of the MainVI... Im calling the SUBvi from it... It is running GOOD n FINE...
    But prob arrives when I call the Main from the SUBvi, which looks like same as MainVI(with little differences).
    I hope, Im clear in my words n not being ambigous.
    Plz, correct me where ever  im wrong.
    Thank You.
    Mishra_RnD
    Attachments:
    ScrShot.JPG ‏272 KB

  • Can I call a "function" from a servlet?

    A few of my servlets need to perform about the same computations (have large sections of identical code).
    It would save some disk space to be able to call a procedure from different servlets.
    Can this be done? How?
    Thank you all.

    A few of my servlets need to perform about the same
    computations (have large sections of identical code).
    It would save some disk space to be able to call a
    procedure from different servlets.
    Can this be done? How?This wouldn't be the way to do it.
    Since Java is an object oriented programming language, you should use it's concepts to implement a 'basic' class and than extend it. This means: Create a class that contains the basic procedures (you will never create an instance of this class) and then create all the serlvet classes by extending the 'mother' class. Like this you have the common code once in the 'mother' class and the specific code in the specific servlets.

  • How can we call actionscript functions from js

    hi
    how can we call Action script function from js file . i
    tried ExternalInterface. add Callback() .but it throws an error .is
    there any other chance to call action script method .thnx in
    advance

    angadala,
    some people have found it is good to include the full
    qualification path, ie
    if (flash.external.ExternalInterface.available)
    flash.external.ExternalInterface.addCallback("ext_method_name",int_method_name);
    } // if (flash.external.ExternalInterface.available)
    There are also browser differences which affect how you find
    the Flex application object which are documented at
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=passingarguments_5.html
    Richard

  • How can I call a variable from another class

    hi
    If I have two classes : one and two
    In class two I have a variable called : action
    In class one I want to check what is the value of action.
    How can I call action?

    Thank you scorbett
    what you told me worked fine, but my problem is that MyClass2 is an application by itself that I don't want to be executed.
    Creating myClass2 as in the following:
    MyClass2 myClass2 = new MyClass2();
    [/code]
    executes myClass2.
    Can I prevent the exectuion of MyClass2, or is there another way to call the variable (action)?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How can I call RFC FM from webdynpro application for ABAP? Please help!

    Hi Experts,
              I have a requirement where I have to make a call to RFC enabled function module passing some data from webdynpro for ABAP application. How can I achieve this? Any tutorial or links or docs will be very helpfull.
    I have seen some tutorial on Adaptive RFC but it talks about webdynpro for Java.
    Can I use "Call function XYZ destination A10" statement in webdynpro for ABAP application?
    Thanks
    Gopal

    am doing same thing for my current SRM implementation.I am taking data to SRM server from another R/3 server .
    This is solution I have used
    1) First of all I have made ABAP connection in SM59 .
    Go to SM59 .In ABAP Connection creat ABAP connection with system with which u want communicate .
    Eg I am connection with Systems PB1.
    So i developed Connection call PB1CLNT800.
    2) In my requirement I have taken data in my context from another r/3,
    I have give called RFC in my supply function of node.
    Call to RFC is as usual.
    In my case,
    CALL FUNCTION 'RFC_MATNR'
    DESTINATION 'PB1CLNT800'
    TABLES
    IT_MATNR = IT_MATNR.
    Onwards I have read my itab IT_MATNR and populated data to context.
    Hope solution will serve your purpose.
    Give point if it works .If any problem i have other ways.
    Cheers
    Parag Bhise

  • How can i call Web page  from my Forms 6 and Some other doubts.

    Dear friends,
    I am having the following questions and doubts ..If you can share some information with me it will be greatly useful to me..
    Q1. I am using Dev Forms 6i. Can we call a Web Page form from the Developer Form directly with the press of a button..(eg. When button Pressed trigger..? )If so, what the requirement to do so. My database is Oracle 8i
    Q2. How can we send email from a Form picking the address from our Oracle Database..? I have installed only Oracle 8i and Forms & Reports 6i. Anymore has to be installed for this work?
    Q3. Do you know any GIS package that can be integrated with Oracle so that we can know the Latitude and Longtude of a lcation if we give an address..? and what can be done for this purpose.
    please revert with the info...
    Sincerly
    Sajith
    12100 Beech Forest Road,
    Laurel, MD 20708, USA
    Phone : (301) 497-5816
    Cell : (301) 693-6767
    Email : [email protected]

    Here is code I used to send an email from Form 6.0 through Outlook 2000 on a PC. I don't know the answer to you rother questions.
    PROCEDURE maily (p_to_address VARCHAR2, p_cc_address VARCHAR2 DEFAULT NULL, p_subject VARCHAR2, p_message VARCHAR2) IS
         objOutlook OLE2.OBJ_TYPE;
         objMail OLE2.OBJ_TYPE;
         objArg OLE2.LIST_TYPE;
    BEGIN          
         objOutlook := OLE2.CREATE_OBJ('Outlook.Application');
         objarg := OLE2.CREATE_ARGLIST;
         OLE2.ADD_ARG(objarg,0);
         objMail := OLE2.INVOKE_OBJ(objOutlook,'CreateItem',objarg);
         OLE2.DESTROY_ARGLIST(objarg);
         OLE2.SET_PROPERTY(objmail,'To',p_to_address);
         OLE2.SET_PROPERTY(objmail,'Cc',p_cc_address);
         OLE2.SET_PROPERTY(objmail,'Subject',p_subject);
         OLE2.SET_PROPERTY(objmail,'Body',p_message);
         OLE2.INVOKE(objmail,'Send');//Use display to display the email instead of sending it, or save to save in the outbox
         OLE2.RELEASE_OBJ(objmail);
         OLE2.RELEASE_OBJ(objOutlook);
    END;

  • How can I call ora:appendToList from java snippet?

    I want to assign a list of user from User Task A to User Task B, but I don't know how to call ora:appendToList from java snippet, and are there any better ways to solve this situation?

    Hi Rakesh,
    Thank you for your help.
    For issue 1, for example, user jcooper apply a vacation, and the request goes to his manager jstein,
    and jstein dispatch the task to mtwain and rsteven for parallel approval, (this is just for example, in
    some case, the manager can use the reassign function), so I use simple workflow pattern for manager approval,
    and parallel workflow pattern for parallel approval, but in my situation, the user for parallel approval is
    uncertain, need select by manager jstein, so I want to know how to assign the user from java code to bpel process.
    The following is how I solve the problem now, put the user list string in flexString1 of simple workflow task,
    then allocate the array for parallel assigneeUsers, then use setVariableData assign the value, it can do the job,
    but the code is awful, I want to know how to do it in some better way.
    <assign name="copyPayloadFromTask">
    <copy>
    <from expression="ora:countNodes( 'inputVariable','task','/task:task /task:assigneeUsers')"/>
    <to variable="currentLength"/>
    </copy>
    </assign>
    <sequence>
    <bpelx:exec name="Java_Embedding_2" language="Java" version="1.4"><![CDATA[
    Element ele=(Element)getVariableData("inputVariable","task","/task:task/task:flexString1");
    String users=ele.getNodeValue();
    String[] userArray=users.split(",");
    setVariableData("arrayLength",new Integer(userArray.length));
    ]]>
    </bpelx:exec>
    <while name="While_1" condition=" (bpws:getVariableData('currentLength')) &lt; (bpws:getVariableData('arrayLength')) ">
    <assign name="Assign_1">
    <copy>
    <from expression="ora:appendToList('inputVariable','task',' /task:task/task:assigneeUsers', string( 'test'))"/>
    <to variable="oraBPMTemporaryVariable"/>
    </copy>
    <copy>
    <from expression="ora:countNodes( 'inputVariable','task','/task:task /task:assigneeUsers')"/>
    <to variable="currentLength"/>
    </copy>
    </assign>
    </while>
    <bpelx:exec name="Java_Embedding_1" language="Java" version="1.4"><![CDATA[
    Element ele=(Element)getVariableData("inputVariable","task","/task:task/task:flexString1");
    String users=ele.getNodeValue();
    String[] userArray=users.split(",");
    for(int i=0;i<userArray.length;i++){
    setVariableData("inputVariable","task","/task:task/task:assigneeUsers["+(i+1)+"]",userArray);
    }]]>
    </bpelx:exec>
    Thanks,
    Ming

  • How can I call a Report From database function

    Hi all,
    I want to call a Report from a database function. Could you hel
    me???
    Rgds

    Hello there!
    There is a solution for executing an executable like RWRUN60
    from PL/SQL on http://asktom.oracle.com/pls/ask/f?
    p=4950:8:227101::NO::F4950_P8_DISPLAYID,F4950_P8_B:150612348067,Y
    Or you can invoke the CGI from the Reports-Server through
    UTL_HTTP
    Hope this helps
    Dannys

  • How can i call a procedure from the app

    hi
    i have an establish connection to a database (MS SQL SERVER 2000) , i can get data from the tabels by sql statments.
    i have stored procedure in the database , how dan i run procedure with parameters from the app.
    lets say i have one procedure that takes one parameter "city_name"
    procedure delete_city ( @city_name char(100) )
    how can i run it
    thanks ahead
    johny

    Hi,
    Assuming con is the connection object:
    Assuming city_name is the name of the city to be passed to the stored proceduer
    Step 1: Create a callable statement object e.g. CallableStatement cs = con.preparecall("{delete_city(?)}");
    Step 2: Set the IN paramter of the stored procedure e.g. cs.setString(1, city_name);
    Step 3: Execute the callable statement e.g. ResultSet rs = cStat.executeQuery(); //assuming only one resultset is returned by your stored procedure
    Step 4: Process the resultset as you do for getting data from your other sql statements.
    This is a very basic way to execute a stored procedure. The complexity lies in executing stored procedures :
    1) which return a value
    2) which will result in multiple result sets
    3) having IN, OUT and INOUT parameters
    4) a combination of any or all of the above
    I would suggest you look up the JDBC API to get more details.
    Regards,
    bazooka

Maybe you are looking for

  • Query failing

    Hi, zzflame_agrt_no & bukrs_vf   are non-primary fields in the table VBAK.     select  vbeln               auart               vkorg               zzflame_agrt_no               bukrs_vf         from  vbak         up to 1 rows       into wal_vbeln    

  • How to speed-up my 1.4ghz PPC Mini?

    I have a 1.4ghz PPC Mini with RAM upgraded from 256mb to [it's max] 1gb. It's running OS 10.4.10 and has all the Apple Software updates. The 80gb HD has 17gb free. It used to be quite zippy, but now it seems to struggle with the most basic tasks; Hav

  • Tochange the string in Std Class Builder "New Method"

    HI freinds, Im using the std program of "RFDOPR10"...(changed into my customised program as ZRFDOPR10)..... Here i want to change the strings of Id_type eq 4 availble under the class builder "New Method". "id_ruler_string = '2.13.24.29|43|58|73|88|10

  • Fireworks Screenshot paste of Windows Media oddity

    If I play an mpeg video in Windows Media Player and take a screenshot using ALT+Print Screen, then paste into Fireworks (or Photoshop), the resultant raster image of the screen shot contains a cut-out rectangle in the middle corresponding to the wher

  • External Debugging parameter Settings

    For this  below settings external debugging  parameterwill be activated , can anyone please check Param. Name abap/ext_debugging_possible Short description(Engl)   To restrict the usage of extern/HTTP debugging Appl. area                ABAP Paramete