Invoke CGI script in JSP?

Hello All:
I tried to use:
<jsp:include flush="true" page="/cgi/test.cgi">to invoke CGI script. The problem is the parameters in request were not passed to CGI. There is no this issue if page invoked is JSP.
I am using SunONE Web Server 6.1
I appreciate you for any consideration.

Well, you can only do that when the new page is complete - probably in the onload event. Which means you have to tell it which field you want to focus - probably by submitting an extra parameter.
Heres a working example:
<html>
<head>
<script language="javascript">
  function saveCurrentField(field){
    document.forms[0].currentField.value = field.name;
  function focusLastField(){
    var lastField = "${param.currentField}";
    document.forms[0][lastField].focus();
</script>
</head>
<body onload="focusLastField()">
<h1>Testing jsp to focus a field on load of the page</h1>
<form>
<table>
<tr><td>Name:</td><td><input type="text" name="name" value="${param.name}" onchange="saveCurrentField(this); this.form.submit();"></td></tr>
<tr><td>email:</td><td> <input type="text" name="email" value="${param.email}" onchange="saveCurrentField(this); this.form.submit();"></td></tr>
<tr><td>Age:</td><td>
  <select name="age" onchange="saveCurrentField(this); this.form.submit();">
    <option>  0-20
    <option> 21-40
    <option> 41-60
    <option> 60+
  </select>
</td></tr>
</table>
<input type="hidden" name="currentField">
</form>
</body>
</html>I wrote it using EL expressions.
If you don't have a JSP2.0 container, or EL is not enabled, replace those ${param.xxxxxx} expressions with <%= request.getParameter"xxxxxxx") %>
Cheers,
evnafets

Similar Messages

  • Servlet engine invoked FROM CGI script?

    Yes this is a backwards request, but I need a simple servlet engine that can be invoked through a CGI script. I perfectly realize the problems associated with this like session management, benefits in threading, etc not to mention the overhead of JVM startup on each request...
    Anything with which anyone's familiar? Searching returns (of course) how to invoke CGI from Servlet containers which is obviously not what I need.
    Thanks!

    Hi Michael,
    I am running 7.0 on Win NT while its the same case its displaying the whole content
    as it is setted the weblogic.servlet.CGIServlet in the web.xml file and providing
    the compiler for perl also .
    Looking for a quick reply
    Thanks
    Shivani
    Michael Young <[email protected]> wrote:
    Hi.
    What platform/OS version are you running WLS on?
    Thanks,
    Michael
    Suren Jain wrote:
    Hi,
    We are having problems invoking cgi scripts from the browser.
    When we try to access it, it is not executed, instead the script is displayed
    in the browser.
    We are using weblogic 5.1 and sp9.
    In the properties file we have specified
    weblogic.httpd.register.cgi-bin=weblogic.servlet.CGIServlet
    weblogic.httpd.initArgs.cgi-bin=\
    cgiDir=/opt/equitydev/geo/cgi-bin,\
    *.pl=/usr/local/bin/perl5,\
    *.sh=/bin/ksh
    Appreciate your help.
    Thanks
    Suren.--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Calling a cgi script URL in a jsp

              I have a requirement of calling a cgi script URL from a jsp.
              I wish to do the following:
              1. take the parameters from the jsp page,
              2. populate the parameters in the cgi script url,
              3. get results in a java structure
              4. and then paint the gui based on the results.
              Can anyone help me on whether calling a cgi script as above is doable in java?
              An early response would be highly appreciated.
              thanks in advance
              Prashant Gupta
              

    Prashant,
              Yes you should be able to do what you ask (using a JSP to drive a CGI
              script/program) if I understand you correctly. You would gather all the
              parameters in the JSP code and present them to the CGI script/program
              using a FORM with method="POST".
              There is a good example of this in the WebLogic examples. Look for it
              somewhere like:
              C:\bea\wlserver6.1\samples\examples\jsp\tagext\form_validation
              in your installation. However, replace action="successPage.jsp" with
              your CGI script.
              Prashant wrote:
              > I have a requirement of calling a cgi script URL from a jsp.
              > I wish to do the following:
              > 1. take the parameters from the jsp page,
              > 2. populate the parameters in the cgi script url,
              > 3. get results in a java structure
              > 4. and then paint the gui based on the results.
              >
              > Can anyone help me on whether calling a cgi script as above is doable in java?
              > An early response would be highly appreciated.
              > thanks in advance
              > Prashant Gupta
              

  • Can i invoke Unix Shell Script using JSP or Java

    Hi
    I am working on developing web application .In this application user will upload a file and this file will be stored on server .once the file is saved i have to invoke shell script which triggers the informatica process to read the file content.
    Can some please assist me on this. If any one have pseudo code for this it will be of great help
    Thanks

    This article has example code and explains how to use it.
    You should read the entire article first.
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Call a Perl Script from JSP

    Hi guys,
    I am developing an online ticket booking system.
    i have come toa point where i need to call a perl script from JSP.
    please let me know how to do it.
    Basically, i need to call a function in perl script from JSP in order to encrypt my information.
    Any help is appreciated.
    Thanks in advance.
    Chintan Shah

    I haven't done this myself, but it seems like it is possible in Tomcat.
    You can configure Tomcat to handle .cgi calls (it does this via a CGI servlet)
    http://www.ftponline.com/javapro/2003_03/online/perl_teden_03_18_03/
    http://tomcat.apache.org/tomcat-5.0-doc/cgi-howto.html
    Once this is set up, theoretically you should be able to then use requestdispatcher and forward/include a cgi script to invoke the perl.
    I don't know if you are using Tomcat or not though... :-)

  • How to include html generated by a cgi-script ?

    Here's the problem:
    I need to include an html-header dynamically generated by a cgi-script: "web_nav.cgi" into my jsp-page.
    According to some documentation the <jsp:include page=... tag can only be used to include servlet, jsp or html files, and according to other sources it doesn't matter what technology the target uses, as long as it delivers html....
    I get a "..include failed, only jsp or html files can be included" error messsage so maybe the first theory is correct.
    But the problem remains: If not with the <jsp:include tag , How do I do it??
    Fast help would be really appreciated.
    Thnx a bunch.
    /Henrik

    Hi Henrik,
    1. the <jsp:include page="local_url" flush="true"/>
    works for local url which is context-relative only
    (within the same server and same context -application-)
    2. So where is your web_nav.cgi ? is it local or remote
    (on another server)
    3. You can do it, look into the jsp book or documentation
    for either jsp:include action and jsp:include directive for your need.
    --Paul

  • Failing to create temp file in Perl cgi script

    This used to work, perhaps before the Apache 2.4 upgrade?
    From the httpd error log:
    AH01215: Error in tempfile() using template /tmp/XXXXXXXXXX: Could not create temp file /tmp/4VmuZsw3Wt: No such file or directory at...
    Here's the offending code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    use File::Temp;
    use CGI;
    my $q = new CGI();
    print $q->header();
    print "Hi mom\n";
    my( $foo, $bar ) = File::Temp::tempfile();
    print $foo "Test content\n";
    close( $foo );
    print "Hi dad\n";
    1;
    If invoked from the command-line, it works as intended. Tried as users me, root and http (the Apache user).
    If run as CGI script, I get this:
    Hi mom
    then it aborts with an HTTP 500, and emits the above message in the error log.
    Before anybody asks:
    drwxrwxrwt 7 root root 240 May 22 20:51 /tmp
    The Apache configuration has this, which /some/path/cgi contains my above script.
    ScriptAlias "/cgi" /some/path/cgi
    Baffled ...

    Restarting Apache fixed the issue. Ran out of file descriptors perhaps?
    The question is: will it happen again?
    Last edited by jernst (2014-05-22 21:20:12)

  • Java script in Jsp Dynpage

    Hi all,
    Can any one give me a sample code for using a java script in jsp dynpage which invokes on client click. I mean i want to call a java script function on client click.

    Hi,
    Check these:
    https://wiki.sdn.sap.com/wiki/display/Snippets/JSPDynPage-Howtohideanelementonclienteventingaswellaschangethetextofthebutton+dynamically
    Search for onClientClick in above link and you will find the corresponding javascript function that is called when user clicks the button.
    Regards,
    Praveen Gudapati

  • Capture output of Perl script with jsp:include

    The company's main web site has a CGI script written in Perl that generates a header, and another one that generates a footer. I would like to deploy a JSP that incorporates the header and footer without having to re-implement the header/footer Perl code in Java.
    Can the <jsp:include> tag include the output from these Perl scripts?

    Well, I tried it. The answer seems to be no.
    I created a simple CGI hello-world thingie and tested it, works fine from a browser (I'm doing all this remotely on a friend's Gentoo box so I know it's not just cached in my browser or anything).
    Then I created a simple JSP and used a fully-qualified URL pointing to the executable CGI script. While the JSP compiles and renders (I had some text in the JSP itself too), the part where it's supposed to include the content of the Perl script doesn't even appear.
    I also tried putting the CGI script into my webapp directory and specifying a relative path to the script, and it doesn't seem to get executed either. To confirm that I'm doing everything right, I put together a simple HTML file that has the same output and changed the "page" attribute to point to that file instead. Sure enough, the output appears.
    So the answer to my question appears to be: no, the output of a Perl CGI cannot be included into a JSP with the <jsp:include> tag. But I'm going to double-check on the Tomcat-user mailing list.

  • CGI Scripts for Mysite website?

    Hi everyone. I'd like to thank you in advance if you give me any information about my following question. I own webspace from Verizon. I don't use the SiteBuilder, but instead I make my webpages from CSS, HTML, Javascript, ect. and use FTP to transfer the files onto my webspace. I have read that Verizon lets users incorporate pre-made CGI scripts into their page, so I thought I'd give it a try. I have been trying to use the "Guestbook" script, following exactly what they say to do to install it. But once I have installed everything into a page and FTP it to my webspace, it gives me a 404 Error, saying it can't find "../guestbook.exe" (after submiting my comment). Can anyone help me with this problem? I followed these directions exactly:
    http://www.verizon.net/central/vzc.portal?_nfpb=true&action=Using%20the%20Guestbook%20Script&_pageLa...
    Please help me. Thank you.

    It seems they have wrong info on there.
    This is the code on my site using the site builder.
    <p>
    <!--gem:tlx.tlx.guestbook-->
    <p align="center"><font face="Arial,Helvetica,sans-serif" size="1" color="cccccc"><b><a href="http://svcs.verizon.net/svcs/dcc.jsp?tpage=upub:index.html&amp;dsrc=gb:842877486280280279/DS_TLXGuestbook_1264975106653.xml&amp;partner=verizon&amp;pcon=yes&amp;xsl=dccfile:gb.xsl&amp;obpp=zlrc2O5cwtTqxMLU6M5QntrawH5c5PrOaGL6yg..&amp;ret_url=http://mysite.verizon.net/your_use_rname/index.html&amp;page=sign"><font color="cccccc"><img border="0" src="/imagelib/sitebuilder/gem/guestbook/sign_my_guestbook_gray.gif"></font></a>&nbsp;&nbsp;<a href="http://svcs.verizon.net/svcs/dcc.jsp?tpage=upub:mypersonalsite/index.html&amp;dsrc=gb:842877486280280279/DS_TLXGuestbook_1264975106653.xml&amp;partner=verizon&amp;pcon=yes&amp;xsl=dccfile:gb.xsl&amp;obpp=zlrc2O5cwtTqxMLU6M5QntrawH5c5PrOaGL6yg..&amp;ret_url=http://mysite.verizon.net/your_user_name/index.html&amp;page=1"><font color="cccccc"><img border="0" src="/imagelib/sitebuilder/gem/guestbook/view_my_guestbook_gray.gif"></font></a></b></font>
    </p>
    <!--end gem--><!--"''"-->
    </p>
    Where your_user_name is what ever my user name is (In your case, what ever your user name is).
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • CGI Scripts in Java

    Can you write CGI scripts in Java or JavaScript and run them on a web server without modifying the server?

    The equivalent of CGI scripts in Java are servlets. To
    run servlets, you need a servlet container. I don't
    know if your web server has a servlet container or a
    way to connect a servlet container to it. Lookup
    information on J2EE (Java 2 Enterprise Edition) on
    this website.The man is correct. Or u can use JSP to the same end. You don't need J2EE tho i don't think...

  • How can i call a CGI script from java?

    The subject pretty much says it all. I want to call a perl cgi script so i can read from/write to files on a server. I don't know how to sign applets and this would be the easiest way for me, if someone could please tell me.

    Let me get this clear. Basically what u want to do is to just call a URL, right?
    U can do it by using the following code:
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    public class testhttp
    public static void main(String[] args)
    try
    URL url = new URL ("http://../testcgi.cfm");
    HttpURLConnection cxn =
    (HttpURLConnection)url.openConnection();
    cxn.setRequestMethod("POST");
    cxn.setUseCaches(false);
    cxn.setDoOutput(true);
    cxn.setDoInput(true);
    ByteArrayOutputStream bytes = new
    ByteArrayOutputStream(400);
    PrintWriter writer = new PrintWriter (bytes,true);
    writer.print("application=map&release=1&items=prog1");
    writer.flush();
    cxn.setRequestProperty("Content-
    Length",String.valueOf(bytes.size()));
    cxn.setRequestProperty("Content-
    Type","application/x-www-form-urlencoded");
    bytes.writeTo(cxn.getOutputStream());
    System.out.println(bytes);
    String currentLine;
    BufferedReader in = new BufferedReader (new
    InputStreamReader(cxn.getInputStream(),"8859_1"));
    while((currentLine = in.readLine()) != null) {
    System.out.println(currentLine); }
    catch(Exception e) { e.printStackTrace(); }
    There is also a library called HTTP client which can be found at:
    http://www.innovation.ch/java/HTTPClient/index.html
    It's very simple to use and the documentation is all there, but their web server seems to be down right now.
    Anyway, hope my post helps.

  • How do I control data transfer rate from Java applications to CGI scripts?

    Hi. I've written a test cgi script which echoes any data it's sent back to the client, and I'm trying to write a java application that reads data from files on my hard drive and sends it to the cgi application.
    The method I've used is the same as the one described in the tutorial on this site, ie. create an URL object, open an URLConnection, get output stream from URLConnection, write data to output stream.
    The problem however is that the java application writes to the output stream at a much faster rate than my internet connection can handle, and so when I try to send more than a few kb the data doesn't seem to get sent at all. Is there some way I can control the rate at which data is sent, or is there a better way of sending data to a cgi application?
    I'd really appreciate any help, thanks!
    Ose.

    I've done some experimenting, and it seems that the problem is with my CGI application and not the Java application after all! (sigh) I wish I hadn't spent those duke dollars now. Oh well.

  • This.submitForm() -- problem with my cgi script

    Thanks to George Johnson for an earlier answer to a related issue with this.submitForm.
    I am trying to use this.submitForm as per Example 1 on p. 348 of "JavaScript for Acrobat API Reference" document.
    To avoid any restrictions with my web hosting service, I am using the following JavaScript (on my form's Submit button) on my local XAMPP server:
    this.submitForm ("./cgi-bin/myscript.cgi");
    My question involves what should be in the myscript.cgi file before I submit to it.  If there is no file to start with, the
    submission will result in a "File not found" error.  So I guess I need the myscript.cgi file in the cgi-bin folder to begin with.
    When I put in a blank myscript.cgi file in that folder (hoping the submission will overwrite it), I can the following message:
    Server error!  The server encountered an internal error and was unable to complete your request. Either the server is overloaded or
    there was an error in a CGI script.
    Can you tell me what is happening?  What should my original myscript.cgi have in it, if anything?

    Thanks for responding.
    I want CGI script to processes the incoming data from the PDF form submission. I want that process to save the FDF to a file on the server. 
    I also understand that the script has to return a response to the client.  I would like to send some kind of confirmation to the client.
    I realize that writing scripts isn't rocket science, but it would seem that Adobe would have some examples of scripts that deal specifically with fdf data.  Could you point me to any examples?

  • Java script with jsp

    hello friends,.
    please help me !! May i know how to retrieve values from list box in java script to jsp and store them in database..i am doing a project Employee Management system....
    please give me ideas .....

    thank you very much sir.......
    i have a combo box in java script having employee skills, if the employee select his skills and click on submit, the values should be stored in the database of the particular employee through JSP..
    the code that i have did is...
    <%
    String s1=(String)session.getAttribute("eid");
    String s2[]=request.getParameterValues ("menu2");
    int i=0;
    %>
    <%
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:empl2");
    PreparedStatement prep=con.prepareStatement("update skill(menu2) values(?) where eid=?");
    // prep.setString(1,s2);
    prep.setString(2,s1);
    i=prep.executeUpdate();
    con.close();
    catch(Exception e)
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body >
    <center><h4><u> Employee Assessment Application</u></h4></center>
    <%
    if(i>0)
    %>
    Your skills had been updated !!!!!
    <%
    else
    %>
    not updated
    <%
    %>
    <br>Best of Luck
    <h4><u>Back</h4>
    </body>
    </html>
    But the values are not getting stored....what to do
    thanx in advance

Maybe you are looking for

  • Display Ids in one row

    Hi I need to avoid extracting the Ids multiple times. That is display first Id for the receipt_no as Primary Id and display the next ocurring ones as associate Ids in one line. There could be more than one associate Ids with one receipt. Any help app

  • How Do I Print Each Frame Separately in the new Firefox

    Before the recent Firefox update, in the print screen used to be an option to print each frame separately. Now, that option is gone. Does anyone know how to have it print each frame separately in the new Firefox? I work with a webpage where if I try

  • Problem with copy serviceorder and personel number

    we have a lot of old serviceorders which can be used as a template for new serviceorders . the only problem is that the personel numbers are copied also. is it possible to prevent that the personel numbers of the old serviceorder are not copied to th

  • Batch derivation in subcontracting process

    Hello experts I ask for your help on the following point: I subcontract packaging operation of a product managed by batch to an external vendor. The bulk (component) I send to the vendor is also managed by batch. I use batch derivation for transferri

  • SHcess is disabled while GRN

    while we do the GRN against the STO migo  is material receipt against the outbound delivery number the material ,Quantity are picked from outbound delivery , after that in the excise tab we will enter the excise no , date, excise group and manually k