Solved

How to use Java for CGI

Posted on 1997-03-05
4
229 Views
Last Modified: 2013-12-25
How can I use Java for CGI under Windows NT 4? How can I run a Java standalone application as if it was a CGI applocation? How can I make the application return HTML to the browser?

Tnx.
0
Comment
Question by:krazy
  • 2
  • 2
4 Comments
 

Author Comment

by:krazy
ID: 1827735
Adjusted points to 100
0
 
LVL 4

Expert Comment

by:pluim
ID: 1827736
What is the problem, exactly? How to write a CGI program in
Java, CGI in general, calling the Java program itself, etc.


0
 

Author Comment

by:krazy
ID: 1827737
Edited text of question
0
 
LVL 4

Accepted Solution

by:
pluim earned 100 total points
ID: 1827738
Ok - I assume you know your way around Java and how CGI
programs work in general. If not, I can fill in any details
you might need.

Create your Java CGI program, e.g.

  class HelloWorld {
    public static void main (String args[]) {
      System.out.println("Content-type: text/html\n");
      System.out.println("<HTML><H1>Hello World</H1></HTML>"
      }

This will return a very simple HTML document.

Now, how to launch this program. Create a batch file
called helloworld.bat, containing:
   x:\javapath\java y:\myprog\HelloWorld

Put this file in your /cgi-bin directory.

Create an HTML form with a button that points to
/cgi-bin/helloworld.bat:
  <form method="POST" action="/cgi-bin/helloworld.bat">
  <input type=submit value="Run Programt"><BR>
  </form>

If you want to pass information from the form to the program
(which is generally why you would use forms in the first
place) things are a little more difficult.
Don't want to take the easy way out, but take look at
    http://www.apl.jhu.edu/~hall/java/#CGI
It has four or five really simple examples which should
get you started - and it saves me from having to cut and
paste that code into this little box.


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question