Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Meenachi Suppiah   on Nov 23 In Java Category.

  
Question Answered By: Woodrow Jones   on Nov 23

I finally had the problem solved! So, for all you
ASP programmers wanting to use a java  class without JSP, Chili-beans,
etc....here's how you do it:

1) Make your Java Class and compile it. Know that it will need to
have all functionality in the method "public class void main(String
args [ ]). For me, I did a ton of System.out.println commands. Since
you are using a browser, ALL valid HTML tags must be included! Ensure
that there is a FORM and that the BODY tag includes the form
submitting itself (in other words, once the page  is completely
loaded, the form auto-submits instead of you or someone else hitting
a submit button!)
Example:

System.out.println( "<html>");
System.out.println( "<body onload=\"LoginForm.submit();\">\n");
System.out.println("<form id=\"LoginForm\" method=\"post\"
Action=\"http://www.myweb.com/VeryNice.asp\">\n");
System.out.println("<input type=\"hidden\" name=\"EncryptedData\"
value=\"" + encrypt(strMessage) + "\">\n");
System.out.println("</form>");
System.out.println( "</body></html>");

So, the form will automatically post back  to my "VeryNice.asp" and
have my decrypted/encrypted data  in a hidden field.

2) Share your java.exe environment  as a website! (very important!)
You do this as a virtual web setting within IIS.
My java.exe was somewhere like c:\program files\java\j2re1.4.0_03
\bin. So I actually set the j2re1.4.0_03 folder as a virtual website
called  "java"

3) Build your asp  to call  the Java.exe with the following code:

dim sXML
sXML = "Hello Jim"
sURL = "http://www.myweb.com/java/bin/java.exe?MyJavaClass%20" &
sXML
Response.Redirect sURL

There's lots you can add on, etc. The "sXML" of "Hello
Jim" would actually be two arguments in to the public static void
main function. Loop through and get them with:

for(int loop_index = 0; loop_index < args.length; loop_index++)
{
strMessage = strMessage + args[loop_index] + " ";
}

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Help using the JRE in ASP Or get search suggestion and latest updates.


Tagged: