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
          

Similar Messages

  • 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
    %

  • How to call a servlet from Webdynpro application

    Hi All,
        I am new to SAP . I have requirement to call a SERVLET which is on a different application server from my webdynpro application , the servlet will return a file .. i need to display that file to the user .. can some one tell me how this can be done .. If possibel please provide some sample code.
    Regards,
    Tarun.

    Hi
    Check this
    1. How to access Servlet information from a webdynpro application ?
    Regards
    Abhijith YS

  • 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.

  • How to invoke a browser from an Application button  with a specified URL

    Hi
    I am trying to invoke a browser by clicking a button on my Application .I want the browser to come up with the URL I decide before i click on the button.
    To invoke the browser i am using the Runtime class. and then using the Runtime.exec() method .
    But thats only half the solution.(Loading a specific URL decided at runtime is a problem)
    Is there a way out ??
    Thanks
    Pranav

    Hi there,
    You have already reach to solution, just specify parameter as your URL to iexplore.exe in Runtime.exec() command.
    Like if you running from command prompt , it will look like something below
    C:>directory where iexplore is>iexplore java.sun.com
    for java Runtime.exec("iexplore.exe","java.sun.com");
    hope it will help you out,
    Dhwanit Shah

  • 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 make data flow from one application to other in BPEL.

    Hi All,
    I am designing work-flow of my application through BPEL(JDeveloper), I am making different BPEL projects for different functions, like sales manager got the order from sales person and sales manager either approve it or reject it, if he approve it it goes to Production manager and he ships the goods, now I want to keep sales person, sales manger,production manager in seperate BPEL files and want to get the output of sales person to sales manager and sales manager to production manager please help me in dong this.
    I was trying to make partner link in Sales manager of sales person and getting the input from there. I dont know this is right even or not, if it is right I dont know how to make data flow from one application to other.
    Experience people please guide.
    Sales Person -----> Sales Manager ----> Production Manager
    Thanks
    Yatan

    Yes you can do this.
    If you each integration point to be in different process, you have to create three BPEL process.
    1. Create a Async BPEL process 'A' which will be initiated when sales person creates the order.
    2. From BPEL process 'A' call a ASync BPEL process 'B' which has the approval flow. Depending on the input from process 'A' the sales manager will review the order in workflow and approve or reject and send the result back to process 'A'.
    3. Based on the result from workflow, invoke the Sync BPEL process 'C', where you can implement the shipping logic.
    -Ramana.

  • Question on "How-to invoke a method once upon application start"

    Hello everyone.
    I'm trying to implement what the article "How-to invoke a method once upon application start" by Frank suggests.
    https://blogs.oracle.com/jdevotnharvest/entry/how_to_invoke_a_method
    Suppose that I'm having a single point of entry, so in my login.jpsx I have the below:
    <f:view beforePhase="#{login.onBeforePhase}">In the method "onBeforePhase" I have to pass the phaseEvent, since the signature is the following:
    public void onBeforePhase(PhaseEvent phaseEvent)but how do I know the phaseEvent when calling the login.onBeforePhase? How the call should be?
    Thanks a lot!
    ps. I'm using jDev 11.1.2.1.0

    You need not pass anything to this method , this method will get called before every Phase except ReStore View
    Just write the logic as Frank suggested for the phase in which you want the code to execute. You can get the PhaseId's like
    PhaseId.RENDER_RESPONSE
    public void onBeforePhase(PhaseEvent phaseEvent) {// from Frank's doc
    //render response is called on an initial page request
      if(phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE){
    ... etc

  • 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 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 send sms port from Desktop applications to the Midlet?

    how to send sms port from Desktop applications to the Midlet?

    Depends on the API your SMS gateway provides, and may not even be possible. Even if you can send the SMS with a port specified, be aware that some carriers deliver the SMS without the port number, which will result in it going to the device inbox and so won't activate your MIDlet registered with the PushRegistry.
    I understand that you're working on a JavaSE application, but members who frequent the mobility forums might have more knowledge about this. Would you like me to move this thread there?
    db

Maybe you are looking for

  • THERE IS NO SOLUTION TO MULTIPLE iPODS ON ONE COMPUTER!

    Hello, This is a very common problem for those of us who belived that iPods were easy to connect to computers. The first iPod was, so why can't I just connect another? Well...you can. It just takes HOURS. Last night, I spent over 4 hours trying to ge

  • ITunes hangs when backing up

    I am trying to back up my iphone 4 so that I can update to the new iOS 5. I have downloaded the new iTunes version 10.5 and since then I can't access the iTunes store or backup my device. I have removed and reinstalled iTunes, I have moved the last b

  • Java.lang.UnsatisfiedLinkError: textureclear

    we have some 3d charts, and one of the user is having some problems with accessing the chart he has JRE 1.5_05 installed and java_home is not set on his machine. we have jnlp file with java3d as library in it like <extension href="http://download.jav

  • I have a question mark over my iPhoto icon.

    I can't find it when I search my apps or trash. I have a MacOSX 10.5.8 and no original discs from installation. I also can't seem to get the Mac App store to run maybe because my Mac is too old? Not sure what to do and I am scared I have lost all my

  • Hp DC5000 Adobe flash player won't install?

    Hello all, I have 2 identical desktop pc's Model HP DC5000 32-bit, after reloading XP PRO SP3 on the first then installing flash player 11 went 1,2,3 but on the 2nd pc I am having hell. I am running XP Pro SP3 and IE8, when I go to Adobe the flash pl