Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have JSP, Have UNIX script, Need middle part

Status
Not open for further replies.

TimeTraveler

IS-IT--Management
Nov 20, 2001
99
US
Here's my JSP page:
Code:
<HTML>
<HEAD>
<% String title = "Foo Test"; %>
<% String foo = "Process p = new getRuntime().exec('./foo_test.cgi');"; %>
<% String bar = "./foo_test.cgi"; %>
<% String bat = "./foo_test.servlet"; %>
<TITLE><%= title %></TITLE>
</HEAD>
<BODY>
<H2><%= title %></H2>
<P>This page is Sean testing how to trigger a UNIX script from a .jsp page.</P>
<P>Going to try using CGI to launch a simple script.</P>
<P><A HREF="<%= foo %>" target="foo_out"><%= foo %></A> Now working</P>
<P><A HREF="<%= bar %>" target="foo_out"><%= bar %></A>This doesn't work either</P>
<P><A HREF="<%= bat %>"><%= bat %></A> Ditto</P>
</BODY>
</HTML>

Here's my script:

Code:
#!/bin/sh
touch $0.foo

Just for kicks, here's a servlet I D/L from the 'net:

Code:
import java.io.*;

// Import servlet packages (requires JDK1.2 or servlet toolkit)
import javax.servlet.*;
import javax.servlet.http.*;


public class MyFirstServlet extends HttpServlet
{
    // We override the doGet method, from HttpServlet, to
    // provide a custom GET method handler
    public void doGet (HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
    {
            res.setContentType("text/plain");
            ServletOutputStream out = res.getOutputStream();

            out.println ("Hello World!");
            out.flush();
    }

    public String getServletInfo() {
        return "MyFirstServlet";
    }
}

What do I do to get the JSP to activate ? (to activate ?...) to activate the UNIX script?

I realize the middle one produced no stdout, but whatever, that's not the point really. The real script will run quiet - no stdout nor stderr, and no user input other than triggering it from the JSP page.

I previously posted this in another forum, and was told to post here.

The directory this resides in is not "seen" by any server except Weblogic. Really, I don't care if the JSP triggers a script (ala CGI) or a servlet (Weblogic/Tomcat/whatever).

Sean (Time Traveler)
[rockband]
 
Well, you can run the script from the JSP using Runtime.exec.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top