How to invoke a servlet from MDB

Hi,
Can someone please tell me how to invoke a servlet from MDB. Actually I want to have a MDB that will invoke a servlet that takes arround ~3 minutes to process and send the response back to MDB. Any small code snippet on invoking a servlet.
Thanks

nope. this is probably a bad design.
but here's a hint: whenever you have a question like this, start browsing the javadocs. chances are there's a class that might help you.
i'd recommend that you look at this:
http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html
%

Similar Messages

  • How to invoke a servlet from an application-URGENT

    Hi,
              My requirement is as follows :
              I have to invoke a servlet from a client application. I am using
              java.net.URL and java.netURLConnection classes to
              open a connection and invoke the servlet.
              I am using WebLogic5.1
              my code snippet is as follows :
              URL url = new URL("http://localhost:7001/urlservlet");
              URLConnection connection = url.openConnection();
              connection.setRequestMethod("GET");
              connection.setDoOutput(true);
              connection.setDoInput(true);
              PrintStream outStream = new PrintStream( connection.getOutputStream() );
              outStream.print("message=hai");
              outStream.flush();
              outStream.close();
              When I execute the application, Webloigc server console is displaying the
              following line.
              <Listen Thread> Adding Address : <machine name><ip address>
              But the service method of servlet is not getting invoked at all.
              Help me to find the answer.
              Jeelani
              

    jeelani <[email protected]> wrote:
              > Hi Dimitri,
              > Thanks a lot.That worked for me.
              > But if I want to send java objects (Vectors,beans),what is the best way to
              > do it.
              > This is exactly what our requirement is..
              If you want to send Java object you have to use POST:
              URLConnection conn = ...
              conn.setDoOutput(true); // makes this a POST
              OutputStream os = conn.getOutputStream();
              ...write your objects here...
              os.flush();
              os.close();
              InputStream in = conn.getInputStream(); // sends data to the server and
              // opens input stream
              ..read servlet response..
              .. ot just close the stream...
              in.close();
              > my client application need to send some java components to our main server
              > located in our head office.The servlet will read the objects and execute the
              > functionality..
              > I really appreciate for the fast response from you.
              > Dimitri Rakitine <[email protected]> wrote in message
              > news:[email protected]...
              >> Try it like this:
              >>
              >> URL url = new URL("http://localhost:7001/urlservlet?message=hai");
              >> URLConnection connection = url.openConnection();
              >> InputStream in = connection.getInputStream();
              >> in.close();
              >>
              >>
              >> jeelani <[email protected]> wrote:
              >> > Thanks for the quick response.
              >>
              >> > Actually right now it doesn't matter whether it is by GET or by POST.
              >> > Add my clinet application just needs to send data to Servlet and nothing
              > to
              >> > get in return.Thats why I am using connection.getOutputStream().
              >>
              >> > since application will not be reading anything from servlet, I don't
              >> > think it is required to use connection.getInputStream().
              >> > (I am sorry, if I am wrong).
              >>
              >> > Can you please help me out. weblogic server is able to get the address
              >> > from where the request is coming. Only problem is servlet is not getting
              >> > invoked.
              >>
              >> > regards,
              >> > Jeelani
              >>
              >>
              >> > Dimitri Rakitine <[email protected]> wrote in message
              >> > news:[email protected]...
              >> >> Are you trying to do get or post? First you set method to GET
              >> >> and then you do the POST.
              >> >>
              >> >> And add InputStream is = connection.getInputStream() - that will
              >> >> result in HttpURLConnection sending data to the server and getting
              >> >> back the response.
              >> >>
              >> >> jeelani <[email protected]> wrote:
              >> >> > Hi,
              >> >>
              >> >> > My requirement is as follows :
              >> >>
              >> >> > I have to invoke a servlet from a client application. I am using
              >> >> > java.net.URL and java.netURLConnection classes to
              >> >> > open a connection and invoke the servlet.
              >> >>
              >> >> > I am using WebLogic5.1
              >> >>
              >> >> > my code snippet is as follows :
              >> >>
              >> >> > URL url = new URL("http://localhost:7001/urlservlet");
              >> >>
              >> >> > URLConnection connection = url.openConnection();
              >> >>
              >> >> > connection.setRequestMethod("GET");
              >> >> > connection.setDoOutput(true);
              >>
              >> >> > PrintStream outStream = new
              >> > PrintStream( connection.getOutputStream() );
              >> >> > outStream.print("message=hai");
              >> >> > outStream.flush();
              >> >> > outStream.close();
              >> >>
              >> >> > When I execute the application, Webloigc server console is displaying
              >> > the
              >> >> > following line.
              >> >>
              >> >> > <Listen Thread> Adding Address : <machine name><ip address>
              >> >>
              >> >> > But the service method of servlet is not getting invoked at all.
              >> >>
              >> >> > Help me to find the answer.
              >> >>
              >> >> > Jeelani
              >> >>
              >> >> --
              >> >> Dimitri
              >> >> http://dima.dhs.org
              >>
              >>
              >>
              >> --
              >> Dimitri
              >> http://dima.dhs.org
              Dimitri
              http://dima.dhs.org
              

  • How to invoke a servlet from the command line

    Hi,
    I have a process that needs to do something remotely. One of the ideas is to have a servlet on the other side that can do that. So the question is how can I invoke it from my process?
    Thanks,

    First approximation to code:URL remoteTask = new URL("http://yourserver.org/yourservlet");
    InputStream response = remoteTask.openStream();
    // read the servlet's response from that InputStreamYou will find more comprehensive versions of this code if you search the forum.

  • Different ways to invoke a servlet from another servlets?

    Hello,
    I am a bit confused today. I was thinking about all the ways by which I can invoke a servlet from another servlets. I know it can be done by creating an instance of the 2nd servlet in the 1st one. Is there any other way? such as say.... RequestDispatcher perhaps?
    Here is an example to illustrate my point. I have a login.jsp which submits to login.do. login.do search through database and first authenticate email and then the corresponding password. Now its time for displayGame.do. So here how do i do? if it was a displayGame.jsp then i could have used Redirection or Forward but when it is servlets? Can I still go for Redirection or Forward??
    Thank you for reading this confused post. :-)

    if it was a displayGame.jsp then i could have used Redirection or Forward but when it is servlets?Question: do you know what a JSP becomes when you first run it?
    Answer: a servlet.
    So yes, you can use a RequestDispatcher to forward/redirect to a servlet OR a JSP, whatever you like.

  • How to invoke crystal reports from Oracle forms 11g R2 along with passing p

    How to invoke crystal reports from Oracle forms 11g R2 along with passing parameter to it.
    how to pass parameters to crystal report, please help.

    how to pass parameters to crystal report, please help.This would entirely depend on crystal reports and you might find informations on crystal reports related communities more likely...I for one have seen crystal reports the last time about 12 years ago. And even back then I simply acknowledged it's existence instead of working with it.
    Maybe crystal reports can be invoked via a URL call which would make it simple as you'd need simply build an URL and show the report using web.show_document. But that's pure speculation. Also you might not be the first with this requirement, so the solution to your problem might be right under your nose and just a little google search away ;)
    cheers

  • How to invoke java application from ABAP

    How to invoke java application from ABAP  ? Suppose I needto execute a EJB wihic is running on my SAP J2EE Enigne from an ABAP Program .
    Thanks,
    Manish

    Hi Manish,
    did you get some further documents concerning "abap program calls ejb"?
    If yes, could you please send me some informations.
    Thank you for your help.
    Kind regards, Patrick.

  • How to invoke a servlet using a tag?

    hi,
    I have written a programme where I need to invoke a servlet from a hyperlink rather than a submit button,which is usually used to invoke a servlet.I hope you can help me out.
    thanks in anticipation
    regards
    Deepa Datar

    Thanks.
    Earlier I didn't get it because I was using doPost() method instead of doget().
    Thanks once again.
    Deepa Datar

  • How to invoke a Servlet on onClick event of CheckBox ?

    Hi,
    Can anybody provide me with the code - how to invoke a Servlet & then pass all form variables to the Servlet on onClick Event of CheckBox in a JSP Page.
    I guess it is possible with Javascript but i need the code...
    Pls Help !
    Thanx.

    <html>
    <head>
    <script language="JavaScript">
    <!--
    function submitMyForm(){      
    document.myform.submit();
    //-->
    </script>
    </head>
    <body>
    <form name="myform" method="POST" action="http://mywebserver/servlet/myServlet" target=_top>
    <input type="checkbox" name="mycheckbox" OnClick = "javascript:submitMyForm()">
    </form>
    </body>
    </html>
    Hope this helps...

  • How to invoke business process from sap xi?

    Hi...
    Please tell "How to invoke business process from SAP UI's."

    Hi...
    How to invoke business process from SAP UI's. (Eg: To trigger a process after creating an invoice)

  • How to invoke the servlet

    how to invoke a servlet using jsp
    containing JSF components
    how can we do this using creator ?
    having sucessfully executed the examples
    still dont know how to do it
    and also jsp source is quite different than normal jsp
    it doesnt allow jsp tags such as
    <%= "asdf"%>any help is great to me
    thanks in advance !
    cheers,
    shekar

    and also jsp source is quite different than normal
    jsp
    it doesnt allow jsp tags such as
    <%= "asdf"%>
    This is jsp syntax -- JSC uses jsf...:-(
    Regards,
    - D.t.O

  • How to invoke BPEL process from JAVA API

    Hi Guys
    Any idea if you can tell me how to invoke BPEL process from JAVA API ?
    What to do in BPEL process manager to achieve that?
    Regards
    Deepak

    See http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/invoke.htm#sthref1373 and the JavaDocs http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm.

  • How to invoke a Servlet method from application

    please help me.the scenario is as follows
    1)a servlet is placed on the server and application has invoked servlet with URL and URL Connection class
    but how do i call a certain method of servlet on the server from the application.Let suppose the servlet's method to be invoked is print(String s).How it can be done from application.

    As GrayMan suggested, Servlets are intended to be used for HTTP communication.
    If you want to open common logic to multiple clients, use EJBs, CORBA or some type of Web Service (SOAP, XML-RPC).
    When you send a request to a servlet, the doPost or doGet method will be invoked. Products such as STRUTS allow you do 'map' to other classes. I suggest avoiding this.
    Personally, I avoid STRUTS like a bad disease. Using STRUTS instead of just learning Servlets/JSP adds a lot of overhead. I prefer performance over development time. A good example of this is that ANY request that comes in over the WEB has ALL variables from the calling page (text boxes, radio buttons and such) made avaialable through the HttpServletRequest.getParameter(String parameterName) method. STRUTS requires you to build a subclass of it's ActionForm classes that is nothing more than a JavaBean with fields that match that of the web page. STRUTS will look at all the parameters in the request and all the fields in the Bean and assign any matches from the request to the Bean. The Bean is instanciated and the matching logic performed just to give you access to objects you already have access to.
    Just my 2 cents, avoid STRUTS like an STD.

  • JDev 10.1.3 how to invoke oc4j_remote_deploy.jar from command line?

    Hi, does anyone know how to invoke the JDev 10.1.3 oc4j_remote_deploy.jar from the command line? We have it working for 10.1.2, for automated deployment scripts.
    If I try the same thing for 10.1.3, I get an error.
    See below my command line and the output.
    I think the error is in the Oc4jDcmServlet URL, the format seems to have changed from 10.1.2 to 10.1.3.
    I tried to reverse-engineer by using an HTTP tracer, but that did not help.
    Any help would be much appreciated.
    Regards, Maarten Brugman
    ======================== command line: ==================
    "C:\j2sdk1.4.2_09\bin\java.exe" -Djava.protocol.handler.pkgs=HTTPClient -jar C:\jdev-work\ebrp-new\ear\target\installer\oc4j_remote_deploy.jar http://lnvx0027:29805/Oc4jDcmServletAPI/ oc4jadmin ***** listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013 UNDEFINED UNDEFINED OC4J_OEBRP
    ============ output: ====================================
    Initializing log
    Servlet interface for OC4J DCM commands
    Command timeout defined at 600 seconds
    Executing DCM command...
    Executing command listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013
    UNDEFINED UNDEFINED OC4J_OEBRP
    Command = LISTAPPLICATIONS
    Opening connection to Oc4jDcmServlet
    Setting userName to oc4jadmin
    Sending command to DCM servlet
    **** Could not check HTTP response code
    ** Thread[main,5,main] ** Fri May 11 17:18:13 CEST 2007 ** ** EXCEPTION: java.
    net.SocketException: Unexpected end of file from server
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:822)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:820)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:635)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:272
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.isHttpResponseOk(Unknow
    n Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.sendCommand(Unknown Sou
    rce)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.execute(Unknown Source
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.listApplications(Unkno
    wn Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmMain.main(Oc4jDcmMain.java:71)
    #### HTTP response is NOT ok
    Closing connection to Oc4jDcmServlet
    #### DCM command did not complete successfully (-1)
    #### HTTP return code was -1
    ============ end output =================================

    In my opinion, you will succeed in handling linefeeds in output texts by using an <tt><af:outputFormatted></tt> tag in conjuction with a JSF converter that replaces the linefeeds with a <tt>&lt;br></tt> tag in the text. You will have to implement a custom converter class (this is quite simple, see below) and to set it to the <tt>converter</tt> attribute of the <tt><af:outputFormatted></tt>. The converter class should look like:
    public class MyLinefeedConverter implements javax.faces.convert.Converter
      public MyLinefeedConverter() {
      public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return value;
      public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value==null) return "";
        if (value instanceof String) return ((String)value).replace("\n", "<br>");
        return value.toString();
    }In this way the linefeeds in your text values will be replaced by <tt>&lt;br></tt>, which will be rendered by the corresponding <af:outputFormatted> tag as line breaks.

  • How to invoke action method from mail contained link

    Hello,
    my application needs to send mails to users that include links for the user to click on. Something like www.mysite.com/displayData.jsp&id=123. My question is now how I make JSF invoke the respective method in the backed bean to display the data with the id 123 when the user clicks on the link int the mail.
    I wonder whether there is some kind of "catch-all action" that checks whether the user is logged in and authorized whenever any JSP page is invoked. I'm a bit tired of first checking the authorization of some user before processing the remaining part od the backed bean's action method.
    Thanks for any hints,
    Oliver Plohmann

    my application needs to send mails to users that
    include links for the user to click on. Something
    like www.mysite.com/displayData.jsp&id=123. My
    question is now how I make JSF invoke the respective
    method in the backed bean to display the data with
    the id 123 when the user clicks on the link int the
    mail.I dont think there is a way to submit to an action on click of a link. Only possible solution is to invoke the method from the constructor of your Backing Bean and populate the bean fields displayed on your page.
    I wonder whether there is some kind of "catch-all
    action" that checks whether the user is logged in and
    authorized whenever any JSP page is invoked. I'm a
    bit tired of first checking the authorization of some
    user before processing the remaining part od the
    backed bean's action method. You can try out a Servlet filter for doing this.

  • Invoking a servlet from an unix shell script

    I have successfully created a servlet that when loaded via a browser takes input values in a form. After hitting "submit" the results are returned to the browser.
    Now I would like to create an unix shell script that:
    1. takes input values from the command line
    2. invokes the servlet that does the necessary processing
    3. returns the results (via echo, or in a text file, etc.)
    Please give me any clues, hints, directions on
    1. how to convert my existing servlet to accommodate a shell script
    2. how to invoke the script within the shell script
    Please refer me to any existing examples if available.
    Thanks,
    George

    Using the code below as an example I think you are saying I should take the following steps in a java sample program:
    1. in a sample program create an Testservlet object -
    Testservlet newservlet = new Testservlet();
    2. to send input to the servlet execute -
    newservlet.doGet( ? , ? );
    I'm not sure what the parameters should look like
    but I guess one of them is the input value.
    3. to get output from the servlet execute -
    String results = null;
    results = newservlet.doPost( ? , ? );
    Again, I'm not sure what the parameters
    should look like.
    public class TESTservlet extends HttpServlet
    String connPool;
    public void init(ServletConfig config)
    throws ServletException
    super.init(config);
    connPool = getInitParameter("dataSource");
    if (connPool == null) {
    System.err.println("This servlet requires a " +
    " dataSource initArg." );
    public void doPost(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    // first, set the "content type" header of the response
    res.setContentType("text/html");
    //Get the response's PrintWriter to return text to the client.
    PrintWriter pw = res.getWriter();
    pw.println("test");
    String testinput = null;
    try
    testinput = req.getParameter("testinput");
    catch (Exception e)
    e.printStackTrace();
    pw.println("testinput = " + testinput");
    finally
    pw.close();
    public void doGet(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter pw = res.getWriter();
    pw.println("Test Servlet");
    putForm(req, pw);
    pw.println("</body></html>");
    pw.close();
    * putForm() writes an HTML form to the response
    public void putForm(HttpServletRequest req,
    PrintWriter pw)
    throws IOException
    pw.println("<form action=\"" +
    req.getRequestURI() +
    "\" method=post>");
    pw.println("<p><strong>Test Input: </strong>");
    pw.println("<input type=\"text\" " +
    "name=\"testinput\" value=\" \" size=12 maxlength=12>");
    pw.println("<p><input type=\"submit\" " +
    " value=\"Submit Entries\" ");
    pw.println("<p><input type=\"reset\" " +
    " value=\"Clear Entries\" ");
    pw.println("</form>");
    } // END OF SERVLET

Maybe you are looking for

  • Adding OR condition gives ORA-00920 error

    I am trying to write a xquery like this - for $VAR3 in document("DS")/db/V_ViewName where (($VAR3/CODE eq $#PARAM of type xs:string) or (xf:empty($#PARAM of type xs:string)))      return      <stuff>           <stuff_name>{  treat as xs:string(xf:dat

  • Locate Acrobat 9 Distiller?

    I'm trying to make a PDF through InDesign through the print menu, however, it gives me a dialogue box for "Please locate Adobe Acrobat Distiller" and I can't find it anywhere. I can find the program, but I can't select it. I'm trying to resize files

  • Bad Customer Services provided by HP

    Compaq 610 I purchased my laptop a years ago. I am finding the issues with my Laptops. Some times I found that my lap is overheated issues. I found that the my laps fan is not working. I called hp and asked them what to do? a week ago. And they provi

  • Individual Compensation Distributions (ICD) error - unexpected error

    Hi Dear All, I have setup ICD for the first time for spot bonus, however, in my first try i am facing Unexcepted error (this is the error I am afraid of lot, always). Details of the error is as follows:- Error Page Exception Details. oracle.apps.fnd.

  • How to declared an array of inner class ?

    can we declare array of inner class ?