How to calling another servlet in a servlet

In my servlet named TransferServlet I want call another servlet named PublisherServlet. So I wrote codes :
objURL = new URL("http://localhost:8080/servlet/PublisherServlet") ;
hucConnection = (HttpURLConnection)objURL.openConnection() ;
hucConnection.setDoOutput(true) ;
hucConnection.setUseCaches(false) ;
hucConnection.setRequestMethod("POST") ;
hucConnection.connect() ;
but i can't invoke PublisherServlet. Why ? pls help
Thanks a lot

you do not need hucConnection.connect(); hucConnection = (HttpURLConnection)objURL.openConnection() does this.
You need to use hucConnection.getOutputStream() and write to the stream to post and if you wanted a response you would need to read from hucConnection.getInputStream()

Similar Messages

  • How to call a Applet from a servlet and vice versa...?

    Hi all
    Can anyone help me how to call a applet from a servlet and vice versa. When the applet is called it should contact the database (oracle8i) and get the data. When i submit the applet form the data in the applet should be saved in the database.
    Thanks in advance
    Kamalakannan

    Sweep is correct about requestDispatcher being another approach for inter-servlet delegation; the only issue that i recall with this approach is that it defaults the method of the destination servlet to the one it was called from...for example, calling servlet2 from within servlet1.post() resulted in the dispatcher attempting to utilize servlet2.post() - i believe that i searched for a parameterize solution to no avail :( (ended up handling the request by placing a "fake" doPost() in servlet2 that simply called servlet2.doGet())
    however, if your application is functioning correctly on your pc/webserver then the problem may be external to servlet communication (e.g. client webserver's ports not configured or blocked, missing runtime classes, etc.)
    my suggestion would be to set aside the programmatic concerns for the moment - what is the response if you open a browser on a client's machine and access the URL in question (i.e. http://clientserver:port/stefanoServlet)? If it will not respond to access in this manner then it certainly won't when your application calls for it.
    It's possible that there is a coding error but, given the info supplied, i'd start examining the environment, first. Let us know if you have any luck with the test i recommended or not (please provide abundant detail). Or, if you've found the solution then you may want to post back with a quick blub so the next person knows how to escape the trap.
    D

  • How to Call another screen using the ABAP Report which is displaying ALV ou

    Hello All,
    I am developing a ABAP report in which I want to transfer the stock from material to another material.
    My Report will include 3 to screens.
    The first sleection screen will display all the material with their stock value.
    When we execute the report I will get the list of materials along with their current stock. On the top of the output screen I want the Execute button. Also , each line of the output should have checkbox or the ALV provides the functionality of editing one cell like that.....Once the user tick the checkbox or the cell....then I want to move to another screen where user can enter the Quantity and then user will tick ok and then I will call one function module so that the material documnet is posted and transfer of posting form material to material is done successfully.
    Could anyone please help me out how to call another screen from the output screen where user can enter the Quantity amount....
    I dont want to use the Dialog programming.....I want to create the simple ALV Abap report.
    Regards,
    Komal Bhutada.

    Hi Raymond,
    Thanks for the input...I will try this in my code .....
    Can you please help me how to insert the checkbox in the ALV Output....so that I can select one of row and then press execute to process further?..
    Thanks for the information.
    Regards,
    Komal.

  • How to call another view controller's method from a view controller?

    Hi,
    Iam new to webdynpro . so pls clarify my doubt.
    How to call another view controller's method from a view controller in the same Web Dynpro Component?
    Thanks,
    Krishna

    Hi,
         The methods in a view are only accessible inside same view. you cannot call it outside the view or
         in any other view although its in same component.
         If you want to have a method in both views, then create the method in component controller and
         from there you can access the method any where in whole component.

  • How to call another program as root in servlet

    In my servlet, I want to call another background programs (writeen in c) to do some tasks and gather the output of them as the output of my servlet. Is there any way to do so like Suexec in apache.
    Thanks

    sorry I forgot mention that the c program required the caller had root privilege.This is the problem I facing now.
    Thanks

  • 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

  • How to call another directory java program?

    Hi All,
    For Example:
    My program is here in two directories.Let Think that directory names like A and B.
    Let Program names like Aprog(A directory) and Bprog(B directory).
    I want to call Aprog to Bprog method.
    How to call?
    Plz., help me ASAP.
    --Mohan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My program is here in two directories.Let
    Think that directory names like A and B.
    It's more complicated than that. A java program consists of multiple .class files. In general you have one or more "trees" of directories of .class files, where the structure of the tree reflects the package structure. So a the class file for "org.dingbat.Thingy" is <basedir>/org/dingbat/Thingy.class where <basedir> is some directory on the class path.
    So referencing one class from another in different directories requires that the source provides the "fully qualified name" of the class (usually on an import) and making sure that, if it's in a different class file tree, both base directories are on the class path.

  • How to call another form ,if option is entered in a text item object ???

    hi ,
    I am created an application ,where in i press a button which call another form having a menu .
    I select any one of the option from the menu ....i enter a number in the text item object of this form ....depending upon what option i have typed .....i would like to call another form ...
    My questions are
    1) Which trigger of this text item should be enabled,and what code to i write in this trigger ?
    2) Since this form is not having any database insert,delete ,update or query (select)
    it should directly go to the new form,whose option i provide in the text item .
    Sunny

    hey bro, i am assuming that ur text item contains the form name, any relevant trigger can be used for user action, like key-enter, post-change or key-next-item.
    to run a form u can use functions call_form or open_form with proper paramters.
    if u want to forward the entered text in the item, use global variable for the session.
    it doesnt matter if the form contains database items or blocks, all u have to do is run the form.
    e.g,
    declare
    VAR VARCHAR2-------;
    begin
    /* u can use the variable to concatinate or modify too, also can use global variable
    var:=:urblock.uritem;
    /* use ur own relevant parameters */
    open_form(VAR,ACTIVATE,NO_SESSION);
    exception
    when---------
    end;

  • HOW TO CALL ANOTHER PAGE USING PL/SQL PDK?

    Hi,
    I am using pl/sql pdk to create portlets. When I need to call
    another page I am using wwpob_page.show(p_pageid) but instead it
    displays File Download wizard.
    Anyone knows workaroud for this?
    Are there any other ways to call other pages with portlets from
    pl/sql portlets?
    Thank you,
    ya

    Hello Yuri
    If you want to call any component of an application from PL/SQL
    you have to take a look to the manage of the component and then
    to Call Interface (Show), There you can see the way to call the
    component, but if you want to call a Page the way I found to do
    it, even thought it is not the best, was put an url like
    this /pls/portal30/url/page/PAGE_NAME on the link.
    I hope this could help you, if you dont understand please let me
    know and I'll give you a hand
    Ana Maria

  • How to call another procedure???

    I create a procedure, and inside this procedure there are others procedures in xxx.sql (vi file)...
    how to call these procedutes???
    Urgent...
    Thanks

    If I understood well u have two sql files, say x.sql and y.sql (u used vi to write them).
    Suppose u want to call y.sql in a certain row of the x.sql file. Then just put inside the x.sql file.
    @y
    If you have a PL/sql procedure inside your sql file, maybe it's different.
    I hav't tried all of the possibilities, but if the procedure u want to call is a stored one, just call its name.
    I hope it helps.
    Bye Dino

  • Urgent! How to add another text field using Servlet

    Hi all,
    I'm using Java Servlet to create a submit page. I want to let users to submit their products and as many as they like.
    What I made several chechboxs of common products on the first part of the page, so that users can simply select from these common products. If they have more to submit, they can click a "Add" button, then another textfield is supposed to appear in the same page below the "Add" button and user can type in, then if they have more, they click "Add", another textfiled should apprear under the first added textfield, so on and so on. After finishing type in all their products, they can click "submit" button to submit to the database.
    I want all the inputed data stay in the same page when user add more and more, so that they can alwasy see and change before submit. I had problem to detect the "Add" button and add new textfield while keeping all the data user has already inputed. How can I do this?
    Tons of thanks!
    Victor

    Hi
    I normally use "hidden" tables for something like this. To accomplish the effect I use JavaScript and a stylesheet. Remember once the servlet sent the page to the browser, it can't interact with it anymore - you'll have to use client side script - which off course you can sent as part of your servlet output :-). I'm including some code that will get you on your way...
    Style Sheet Code:.hide {display:none};
    .show {display:block};
    Java Script Code:var current = 0;
    function showMore() {
      if (current < 5) {
        current++;
        switch (current) {
          case 2:
            document.getElementById("showme2").style.display = "block";
            break;
          case 3:
            document.getElementById("showme3").style.display = "block";
            break;
          case 4:
            document.getElementById("showme4").style.display = "block";
            break;
          case 5:
            document.getElementById("showme5").style.display = "block";
            break;
    function showLess() {
      if (current > 1) {
        switch (current) {
          case 2:
            document.getElementById("showme2").style.display = "none";
            document.forms[0].term[1].value = "";
            break;
          case 3:
            document.getElementById("showme3").style.display = "none";
            document.forms[0].term[2].value = "";
            break;
          case 4:
            document.getElementById("showme4").style.display = "none";
            document.forms[0].term[3].value = "";
            break;
          case 5:
            document.getElementById("showme5").style.display = "none";
            document.forms[0].term[4].value = "";
            break;
        current--;
    Extract from JSP page (easy to convert to normal servlet code):<!-- first row allways visible -->
    <table id="showme1" cellpadding="3" cellspacing="0" class="show">
         <tr><td><input type="text" name="someitem"></td></tr>
    </table>
    <!-- hide the rest for now -->
    <% for (int i = 2; i < 6; i++) { %>
    <table id="showme<%=i%>" cellpadding="3" cellspacing="0" class="hide">
         <tr><td><input type="text" name="someitem"></td></tr>
    </table>
    <% } %>There are other ways to do the JavaScript, but the code above is cross-browser :-). You'll see with the switch statement in the JavaScript, that there is a limit to the rows that gets displayed - adjust as you please, just remember to also update the loop that generates the tables. Also note that each text field has the same name! The result of this is that an array of these fields are submitted, so you're recieving servlet will need to loop through the array basically take appropriate action on the fields that don't contain an empty string. Something like:String[] items = request.getParameterValues("someitem");
    for (int i = 0; i < items.length; i++) {
        if (!items.trim().equals("")) {
    //do something

  • How to call a stored procedure from servlet?

    Hi all
    We are developing a project in servlet which needs to call a stored procedure in oracle 8i database.How to make a call? Whether can i get any data from the database using STORED PROCEDURE
    THANKS IN ADVANCE
    kamalakannan

    Hello,
    You can do an HTTP call from a store procedure using thre UTL_HTTP package; so you should be able to call your servlet this way.
    See UTL_HTTP documentation
    Regards
    Tugdual Grall

  • How to Call SQL Loader from Java ( servlet )?

    We need to call SQL Loader command from Java Servlets? Any suggestions how this can be done?
    Thanks
    Rahul

    Probably not the best way, but you could try using JNI to call a C function which then invokes SQL Loader via system() or exec(). I haven't done this myself though...

  • How to call Jasper Reports from a Servlet?

    hi! i am a newbie in Jasper Reports. Can somebody tell me how i am supposed to let my jasper-created report appear in my web app? i am using JSP/Servlet framework, and basically what i need my app to happen is when i click on my View summary page button, my PDF-generated jasper report would automatically display without me having to save a pdf file in my disk. Codes would be really greatly appreciated.. thanks in advance...

    Hello,
    welcome to the JDC forums. You've opened three threads (which is good as you ask 3 different questions). I suggest you edit the 2 other rheads ( ["tree and table"|http://forums.sun.com/thread.jspa?threadID=5416646&tstart=0] and ["open internal frame"|http://forums.sun.com/thread.jspa?threadID=5416647&tstart=0] ) so that each one deals with one question at a time.
    I also suggest that you take the time to write your posts, and don't use SMS abbreviations. It shows some respect and will help attract people to answer you. If you're in such a hurry that you can't even afford spelling full words, then you're screwed anyway.
    Good luck.

  • How to call any .tmpl file from servlet by sending some parameters ?

    Hi,
    I am new to Java Servlet and HTML template language ( anyfile.tmpl).
    I have created simple login authentication with user registration for new user.
    If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
    Thank you.
    if (session == null) {
         try {
              userName = request.getParameter("login");
              pwd = request.getParameter("password");
              if (!userName.equals("") && !pwd.equals("")) {
              try {
    //Database connection, data fetching, query execution etc.
    // code will go here
                   while (rs.next()) {
                   if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
                        String u_name = userName;
                        String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
                        String address = rs.getString("address");
                        session = request.getSession();
                        session.setAttribute("user", userName);
                        String inbox = context.getInitParameter(INBOX);
                        Template inboxTmpl = new Template(inbox);
    *                    inboxTmpl.setParam("userName", u_name);*
    *                    inboxTmpl.setParam("ph_no", ph_no);*
    *                    inboxTmpl.setParam("address", address);*
    *                    out.println(inboxTmpl.output());*
                        System.out.println("Login successful..");
                        break;
                   rs.close();
         pstmt.close();
    con.close();
    (P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}

    Where does Template come from?
    But its not working.The other day I called the car repair shop. I told them my car did not work and I wanted them to fix it. They asked what was wrong, whether it did not start, whether suspicious sounds were heard, whether the car did not want to brake any longer, whether it gave a smoke from the exhaustion, whether the wind shield was broken, whether the oil was leaking etc. But I insisted just telling them "it doesn't work".

Maybe you are looking for

  • Aperture 3 library syncing question

    I want to move to Aperture, but I need some advice first. (I have considered Aperture in the past, but my expectations and demands were unrealistic. Now I am trying to be as realistic as possible about what I want from Aperture.) I have learned that

  • How to create a Parameter dependent over another parameter for ESS job

    Hi Team, We have defined an ESS job for which we have 2 parameters (parameter values are based on LOV). Now we have to make these parameters dependent. Any inputs on this are highly appreciated. Thanks, Praveen

  • Best brand to use in PC to connect to AE

    Hi- I just inherited a 2 or 3 year old HP PC. Seems pretty decent. Runs XP, plenty of RAM and an upgraded graphics card. I want to hook it to my TV for some big-screen web browsing with the family. The rest of my household network is all Mac. I curre

  • Get time machine to see old backups

    Hi all, recently i had a problem that resulted in having to restore from a time machine backup. Since then i have been unable to see my previous backups within time machine The sparse bundle is still intact, i have not allowed it to backup knowing th

  • Red Information in Netbeans 6

    Hi, receive flg. information if i run a project Qoute... Trying to override old definition of task nbjavafxconnect Trying to override old definition of task nbjavafxstart Trying to override old definition of task nbjavafxreload Trying to override old