Solved

How to use Java for CGI

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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

14 Experts available now in Live!

Get 1:1 Help Now