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!

Combo not working - Tomcat 5.5, CGI, Windows XP Home, Batch Files

Status
Not open for further replies.

TimeTraveler

IS-IT--Management
Nov 20, 2001
99
US
Alright folks,

As usual, searching posts in a the form and FAQs has yielded zipola, so I'm again asking what some may consider to be annoyingly easy and or bizzare.

Here's my stack:
[ul]
[li]Windows XP Home[/li]
[li]Batch file(s)[/li]
[li]Tomcat 5.5[/li]
[/ul]

Here are my constraints:
[ul]
[li]Limited Java/JSP/Servlet experience[/li]
[li]Windows XP Home[/li]
[li]CGI must use Windows XP Home 'cmd.exe' vs. 'perl' (for now)[/li]
[li]Not loading Apache or anything else[/li]
[/ul]

I'm prototyping a concept for work, that'll eventually be moved over into a Linux Weblogic environment.

Please do not reespond with "why are you doing that?!" or "just do ..." or anything response that doesn't include SPECIFIC code examples and file locations. Though I thank you for your time, posts like that are time wasters.

What I've done so far:

[ol]
[li] Installed Tomcat 5.5 and Admin package and it works[/li]
[li] Developed a callable DOS batch file
[/li]

[li] Created webapps\foo\index.jsp
[/li]

[li] Uncommented cgi and cgi mapping entries in conf\web.xml
[/li]

[li] In conf\web.xml I added the entry for executable to use 'cmd /q /c'
[/li]

[li] Renamed server\lib\servlets-cgi.renametojar to server\lib\servlets-cgi.jar
[/li]
[/ol]

And I'm getting a variety of errors from 404 to requested service not available and all of it.

Here are my files. Filename and locations noted inside the code.

Code:
:: filename: webapps\ROOT\cgi-bin\time.bat
:: purpose:  generate some trivial output to test Tomcat 
CGI
echo Content-type: text/html
echo.
echo.
echo ^<html^>
echo ^<body^>
echo ^<P^>Time is 
time /t
echo ^<^/P^>
echo ^<^/body^>
echo ^<^/html^>

Code:
<!-- filename: webapps\foo\index.jsp -->
<!-- purpose:  trigger a DOS batch file via CGI in Tomcat -->
<html>
<head>
<% String title = "foo page"; %>
<% String doThis = "/cgi-bin/time.bat"; %>
<title><%= title %></title>
</head>
<body>
<h2><%= title %></h2>
<P>Click button to see time.</P>
<form method="POST" action="<%= doThis %>">
<input type="submit" value="<%= doThis %>"></input>
</form>
</body>
</html>

Thanks in advance for any SPECIFIC help.

-Sean aka TimeTraveler
[rockband]
 
Well, I figured this out, partially.
I can get the [tt].jsp[/tt] to trigger the [tt].bat[/tt] file from the centralized [tt][blue]webapps\ROOT\WEB-INF\cgi[/blue][/tt] directory, but not from [tt][blue]webapps\foo\WEB-INF\cgi[/blue][/tt] directory.

The entries in the [tt][blue]conf\web.xml[/blue][/tt] file aren't quite the defaults.

Code:
...
  <!-- note forward slashes even though on Windows... -->
  <param-name>cgiPathPrefix</param-name>
  <param-value>WEB-INF/cgi</param-value>
...
  <!-- 
       Have to use /c here even though a .bat file and 
       not a regular command.  The /q gets rid of the 
       need to turn echo off.
  -->
  <param-name>executable</param-name>
  <param-value>cmd /q /c</param-value>
...

  <!-- And under mapping... make sure 'cgi' points to '/cgi-bin' -->

I'll post a FAQ here either later today or sometime this week on this.

The point of this wasn't to run [tt].bat[/tt] files as it was to test whether [highlight]Tomcat 5.5[/highlight] really can support [highlight]CGI[/highlight] in general, and gain some understanding I can take to doing the same thing on [highlight]Weblogic[/highlight].

Thanks to everyone who may have looked at this during the interim.

Sean aka Time Traveler
[rockband]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top