Solved

How to use Java for CGI

Posted on 1997-03-05
4
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

617 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