Solved

How to use Java for CGI

Posted on 1997-03-05
4
228 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bulk Changes to WP permalinks in .htaccess - blog post only 4 77
Adapting Windows 7 Image for all HDD size 7 82
Sums of coloumns in html/java 15 66
Recursively Delete Files 5 68
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now