Using Perl From Java!

Hi there, i have an assignment for university, part of it is to send data to a perl script through a Java applet. My perl script works, as i have tested it with a HTML form, however when i try it with java, i get nothing, nothing, no errors or warnings. Im using JBuilder6.
I am convinced that there is a problem with my code and a connection is not being opened, my lecturer cant see what the problem is (im not too impressed!) so i come to you.
All the perl does is create a file called test.txt and print within it the name, email..etc from the applet.
Thanks in Advance, Dave Williams.
JAVA:
void btnSendPosting_actionPerformed(ActionEvent e) { //Send Posting Event
name = txtName.getText();
email = txtEmail.getText();
message = txtareaText.getText();
path = txtFilePath.getText();
String url = "http://localhost/cgi-bin/diag.pl";
System.out.println("Url entered");
try
theURL = new URL(url);
System.out.println("Url prepaired");
catch (MalformedURLException f)
System.out.println("Bad URL: " + theURL);
try
System.out.println("Beggining Connection...");
URLConnection connection = theURL.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.print("txtName="+name +"&txtEmail="+ email +"&txtMessage="+ message +"&txtPath="+path);
out.close();
System.out.println("End of Connection");
catch (IOException f)
System.out.println("Error Opening Connection");
} //Send Posting Close bracket

Hi All heres the code with the propper tags i think, as for smorgasbords comment, I realise the security issue with java, but my lecturer seems to think its a good idea. Now the java applet opens a stream to my perl script and sends it parameters which the perl script uses to create the file. So java isnt making the file on any computer, perl is creating it on the server (EasyPHP actually). The example code given by my lecturer does actually work however for reasons which neither myself or the lecturer cannot see, it just doesnt create the file (or even open the perl script for that matter, as i used a file monitor to check if the 'diag.pl' file was accessed). I hope ive cleared up any questions.
Thanks
Dave
void btnSendPosting_actionPerformed(ActionEvent e) { //Send Posting Event
name = txtName.getText();
email = txtEmail.getText();
message = txtareaText.getText();
path = txtFilePath.getText();
String url = "http://localhost/cgi-bin/diag.pl";
System.out.println("Url entered");
try
theURL = new URL(url);
System.out.println("Url prepaired");
catch (MalformedURLException f)
System.out.println("Bad URL: " + theURL);
try
System.out.println("Beggining Connection...");
URLConnection connection = theURL.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.print("txtName="+name +"&txtEmail="+ email +"&txtMessage="+ message +"&txtPath="+path);
out.close();
System.out.println("End of Connection");
catch (IOException f)
System.out.println("Error Opening Connection");
} //Send Posting Close bracket

Similar Messages

  • How to run Perl from Java

    Hi,
    I have a program written in Perl. I want to run the Perl program using Java. If there is a command which can allow me to call the perl program from Java program, please advise me.
    regards

    The most easy way is to use Runtime class to call "perl" to run your perl script.
    String sCmd = "c:\\yourPerlScriptLoc\\yourPerlScript.pl";
    Process p = Runtime.getRuntime().exec(sCmd);

  • Using XPath from Java

    I've heard that you can use XPath from within Java instead of having to use it within XSLT, but I'm not sure what the syntax is?
    Does anyone know?
    Thanks,
    Oodi

    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xpath.XPathAPI;
    DOMParser parser = new DOMParser();
    parser.parse(inputFile);
    doc = parser.getDocument();
    /* Search using XPATH */
    String xpath = "/XpathToSearch";
    NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);
    HTH,
    Joe

  • Calling perl from java applets

    I have problems in executing PERL from a JAVA applet and Swing interface.
    I'm working under Windows 98.
    My aim is the following:
    When I click on the "Analizza" button,
    I want to execute a PERL program and automatically
    close the DOS window after completion. If there
    is an error, this error should be displayed in DOS.
    I wrote this piece of code
    public void actionPerformed(ActionEvent eventoUtente){
         String comandoPulsante = eventoUtente.getActionCommand();
              if (comandoPulsante == "Analizza"){
              Runtime rt = Runtime.getRuntime();
              try{
              Process pr= rt.exec("cmd -c c:\\command /c perl C:\\_webasco\\contatutto2.pl");
              catch(java.io.IOException ioEx)
              System.out.println("IOEx:"+ioEx.getMessage());
    I tried also with a Windows executable, ie I replaced the line
         Process pr= rt.exec("cmd -c c:\\command /c perl C:\\_webasco\\contatutto2.pl");
    with
         Process pr= rt.exec("command /c c:\\windows\notepad.exe");
    but in both cases nothing happens within the applet.
    What am I doing wrong????
    Any suggestions is warmly welcomed.
    Thank you
    Marina

    I know nothing about Perl, but the line
    if (comandoPulsante == "Analizza"){
    compares references not values and will always return false. Try:
    if (comandoPulsante.equals("Analizza")) {

  • Perl from java

    hi ..
    i want to generate a graphical report after anlysing a log file... i have parsed it with perl....but how do u get the return values into the java prog to generate the graphical report..
    pls help me... i am new to perl with java........

    How about writing the perl script such that it outputs a file of data, then write a java program that reads the data and plots it?

  • Using JNDI from Java Stored Procedures

    Hi,
    we want to call external services (mostly via middle tier/J2EE) from within the database (9i Rel. 2) using Java Stored Procedures and JNDI.
    Does anybody have some hints/samples how to do this? Will we have to use oc4jclient.jar? If yes, how? Where can I find some more detailed documentation?
    Lot's of questions...
    Thank
    Matthias

    Uh, not JNI but JNDI you asked. And use of JNI should be generally discouraged unless there is absolutely no other way (like co-located CORBA code for decoupling+speed). Can you direct me to a HOW-TO Oracle DB JVM configuration page? I want to know how to configure the internal DB JVM in a hurry.
    Thank you,
    Bryan

  • Connecting to AW using AWConnection from java

    Hi all,
    I have some java code which performs some AW manipulation based on relational tables, the code works perfectly both inside the database and externally.
    The problem I have is that I don't want to have to pass the username, password, and connectstring into the java procedure. I want to take advantage of the "kprb" type connection, i.e. I want to be able to use the defaultConnection method of the Oracle driver like I would with jdbc: the session has already been connected by sqlplus
    I can't work work out if this is possible via the AWConnection method, I guess it must be using a loopback type connection based on the tnsnames.
    Anyone know if it can be done?
    Cheers,
    Mark...

    Hi Mark,
    The AWXML api has a mode which does exactly what you want, you should create an Interaction object which contains a set of actions you want to perform. This object can then be serialized into xml by calling the writeToXML method on it. At this point, you can use the returned string to create a clob which is then passed to a pl/sql procedure called sys.interactionexecute. This procedure takes the xml as a clob and executes it in the internal jvm using the connection information from the envoker of the pl/sql procedure.

  • Using COM from java

    hi all,
    I'm trying to find a way to call functions from a C++ COM object (.tlb).
    Since I don't have a clue about C++ I thought about using an API or Tool that will help me to generate the appropriate wrappers and stubs to use with java.
    Does someone have any idea of an API or Tool which is suitable for the above scenario?
    many thanks in advance..........

    See
    http://simtel.net/product.php[id]60701[sekid]0[SiteID]simtel.net

  • JNI : Unsatisfied Link Error using C++ from Java

    Am using JNI to call a C Function which in turn creates a new C++ object and calls a method on it.
    When I run the java program that calls this native method, I get a UnsatisfiedLinkError : No <lib> in java.library.path.
    If I change the C function to do a simple printf instead of creating a new object , it works fine.
    I am printng out the java.library.path before calling the loadLibrary method, the path is correct.
    Am using Java 1.2.2 and compiling with gcc 2.7 on solaris 2.6 (Sun OS 5.6)
    Any help would be appreciated. I have seen some other folks having similar problems but haven't seen any replies that seem to solve the problem.

    Thanks for the ldd suggestion :
    This is the output from ldd
    ldd -sir liba.so
    find library=./liba.so; required by /usr/lib/lddstub
    find library=libe.so; required by ./liba.so
    search path=/user/ajax/jni (LD_LIBRARY_PATH)
    trying path=/user/ajax/jni/libe.so
    libe.so => /user/ajax/jni/libe.so
    symbol not found: strcpy (/user/ajax/jni/libe.so)
    symbol not found: strcpy (/user/ajax/jni/libe.so)
    symbol not found: printf (/user/ajax/jni/libe.so)
    symbol not found: printf (/user/ajax/jni/libe.so)
    symbol not found: __builtin_new (/user/ajax/jni/libe.so)
    symbol not found: printf (/user/ajax/jni/libe.so)
    init library=/user/ajax/jni/libe.so
    init library=./liba.so
    libe.so is in the LD_LIBRARY_PATH
    The 'man' pages for ldd say this :
    Using the -d or -r option with shared objects can give misleading results. ldd does a "worst case" analysis of the shared objects. However, in practice some or all of the symbols reported as unresolved can be resolved by the executable file referencing the shared object.
    Most of them seem ok, but I am wondering about "__builtin_new", anyone know what shared lib that's supposed to be in ?

  • Using ByteBuffer from java.nio package

    Hi,
    I have a java.nio.ByteBuffer object that is returned from the C++ code, created using NewDirectByteBuffer. I would like to use this ByteBuffer object in my java code to create a WritableRaster object. I would like to avoid an array copy here as the data may be huge.
    Could someone please let me know if there is a solution to this?
    Thanks in advance for any help.

    Warning: I know almost nothing about the java.awt.image package - so please take what Im going to suggest as the throw away, off the top of my head random rambling that it is......
    Could you implement a custom DataBuffer which sits on top of a NIO ByteBuffer? Already, custom DataBuffers provide access for certain data types (e.g. theres a DataBufferByte, DataBufferDouble which wrap arrays) - so I guess you could write a NIODataBufferByte - or what ever - which sits on top of a ByteBuffer.
    Im not sure how this would tie in with the SampleModel though (again, I dont know anything about this area).
    Hopefully someone who knows this stuff will come across this thread and actually give you some decent advice :o)
    ~D

  • Using perl Inline::Java and the BO SDK

    Hi, I'm looking for someone who's successfully used BO SDK though the Inline::Java perl module. I have only so far been able to connect to the CMS. I was hoping to see examples of report development, user management, server management, anything.
    Thank you,
    Mike

    Hi All heres the code with the propper tags i think, as for smorgasbords comment, I realise the security issue with java, but my lecturer seems to think its a good idea. Now the java applet opens a stream to my perl script and sends it parameters which the perl script uses to create the file. So java isnt making the file on any computer, perl is creating it on the server (EasyPHP actually). The example code given by my lecturer does actually work however for reasons which neither myself or the lecturer cannot see, it just doesnt create the file (or even open the perl script for that matter, as i used a file monitor to check if the 'diag.pl' file was accessed). I hope ive cleared up any questions.
    Thanks
    Dave
    void btnSendPosting_actionPerformed(ActionEvent e) { //Send Posting Event
    name = txtName.getText();
    email = txtEmail.getText();
    message = txtareaText.getText();
    path = txtFilePath.getText();
    String url = "http://localhost/cgi-bin/diag.pl";
    System.out.println("Url entered");
    try
    theURL = new URL(url);
    System.out.println("Url prepaired");
    catch (MalformedURLException f)
    System.out.println("Bad URL: " + theURL);
    try
    System.out.println("Beggining Connection...");
    URLConnection connection = theURL.openConnection();
    connection.setDoOutput(true);
    PrintWriter out = new PrintWriter(connection.getOutputStream());
    out.print("txtName="+name +"&txtEmail="+ email +"&txtMessage="+ message +"&txtPath="+path);
    out.close();
    System.out.println("End of Connection");
    catch (IOException f)
    System.out.println("Error Opening Connection");
    } //Send Posting Close bracket

  • Example code for Trigering a workflow using WAPI from JAVA based tool

    Hi Experts,
    I am the newest guy in SAP workFlow and BAPI world. I need to trigger a workflow defined in WebFlow engine from a Java client. I know i can use JCo and to use WAPI to get workflow information but i am not sure how it works. Can you give me some example code to trigger one workflow defined in WebFlow using WAPI? If there is any alternative i am interested to know that as well.
    Thanks in advance.
    Regards,
    Riyadh

    Use Function Module SWE_EVENT_CReate top trigger event that is linked with a Workflow.
    <b>Please reward points if useful</b>
    INCLUDE <cntn01> .
      DATA:i_emp_details TYPE STANDARD TABLE OF p0001,  "Employee Details
           wa_request    TYPE p0001,                    "Workarea for Employee details
           v_country_grp TYPE molga,                    "Country SubGrouping
           v_object_key  TYPE sweinstcou-objkey.        "Key for the buisness object ZWOBUSTRIP
      CONSTANTS: c_bo_trip     TYPE swo_objtyp VALUE 'ZWOBUSTRIP',
                 c_event_trip  TYPE swo_event  VALUE 'TripCreate',
                 c_infy_type_1 TYPE infty      VALUE '0001'.
    Event Container declaration
      swc_container i_event_cont.
      swc_create_container i_event_cont.
    Reading the INFO TYPE 0001 to obtain the
    Employee details
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = i_emp_number
          infty           = c_infy_type_1
          begda           = sy-datum
          endda           = sy-datum
        TABLES
          infty_tab       = i_emp_details
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
    SY-SUBRC check is not required as the error
    handelling will be done by WorkFlow rule
    resolution.
      CLEAR wa_request.
      READ TABLE i_emp_details INTO wa_request INDEX 1.
      IF sy-subrc = 0.
      Retrieving the Country SubGrouping for the employee
        SELECT SINGLE molga
          FROM t001p
          INTO v_country_grp
         WHERE werks = wa_request-werks
           AND btrtl = wa_request-persk.
      ENDIF.
    Sending the relevant data to event container
      swc_set_element i_event_cont 'EmpId'     i_emp_number.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
      swc_set_element i_event_cont 'PersonnelArea'    wa_request-werks.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
      swc_set_element i_event_cont 'CountryGrouping' v_country_grp.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
      swc_set_element i_event_cont 'EmpSubGrp'       wa_request-persk.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
      swc_set_element i_event_cont 'EmpTripId'       i_emp_trip.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
    Raising the event to trigger the workflow
      v_object_key = i_emp_number.
      CALL FUNCTION 'SWE_EVENT_CREATE'
        EXPORTING
          objtype           = c_bo_trip
          objkey            = v_object_key
          event             = c_event_trip
        TABLES
          event_container   = i_event_cont
        EXCEPTIONS
          objtype_not_found = 1
          OTHERS            = 2.
      IF sy-subrc <> 0.
    No Processing needed.
      ENDIF.
      COMMIT WORK.
    ENDFUNCTION.
    Thanks
    Arghadip

  • How can i use twain from java servlet?

    dear all
    iam a web developer ,iam haviving now a task to search in point pf scanning image through web (Intranet) using java
    can any one tell where can i find resources how to deal with Twain using java (On web specially not from a desktop application)
    i hope u can help me
    Thanks in advance
    Yours,
    Amr
    Senior Java Web developer

    Hi,
    You can try a package named: JTwain, which is available at http://asprise.com/product/jtwain.
    JTwain supports all kinds of digital cameras and scanners. You can use Java to access, contorl digital cameras and scanners, and of course, to acquire images with flexible settings.
    The developers' guide is available @ http://asprise.com/product/jtwain/devGuide.php
    In the simplest case, one line of Java code can solve your problem.
    Good luck!

  • Problem in using Timestamp from java.sql.*

    AOA
    i have declared a variable
    private Timestamp entryDate = new Timestamp(8);while using it in my application. it inserts similar time stamp in database , like
    01/01/1970 5:00:00 AM
    How to get current time from it and how to insert it in databse.

    AOA
    i have declared a variable
    private Timestamp entryDate = new Timestamp(8);
    Why? What does that 8 mean to you? Did you read the docs to see what it means to Timestamp?
    >
    while using it in my application. it inserts similar
    time stamp in database , like
    01/01/1970 5:00:00 AM
    How to get current time from it and how to insert it
    in databse.Did you read the docs for Timestamp? There's a constructor and/or a set method that takes a Date or a number of millis. You can get the current time in millis with System.currentTimeMillis. (I think that's the method name. Look at System's docs.)
    As far as inserting it, you'll do something like this: TimeStamp ts = ...;
    Connection con = DriverManager.getConection(...);
    PreparedStatement ps = con.prepareStatement("insert into foo (bar) values (?)");
    ps.setTimestamp(1, ts);
    ps.executeUpdate(); Google for jdbc tutorial for more details.

  • Using DCs from Java DC

    I need to use tc/wd/webdynpro (default) DC in a Java DC. I add it in Used DCs with Build Time (and I also try with build, design, run time...), compile and deploy successfull but when I run web dynpro DC that use Java DC (deployed with J2EE DC), the class IWDNodeNotificationListener is not found.
    ¿What option I need to use tc/wd/webdynpro DC in runtime?

    Hi Sebastian,
                          I guess this is the problem with required class or package not defined.  check this link once.
    http://www.petsounds.org/sapjavadocs/webdynpro/com/sap/tc/webdynpro/progmodel/api/IWDNodeNotificationListener.html
    Regards,
    Anil.

Maybe you are looking for