Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Help using the JRE in ASP

  Asked By: Meenachi    Date: Nov 23    Category: Java    Views: 729
  

I must mix Java technology (specifically,
encryption classes) with the Microsoft ASP environment.

I've successfully been able to call the JRE from an ASP to get some
basic data printed to the screen. However, I need to pass those
parameters back to the page that called that from but am stuck.

From Page1.asp I call the Java Runtime Environment to encrypt some
data (using clients Java classes) by:
http://myservername/java/bin/java.exe?WNEncrypt%20Encrypt%20this

to encrypt the text "Encrypt this".

I can get it to print (using System.out.println) to the screen fine
with the encrypted data, but I've no idea how to actually grab the
encrypted data or pass it back. I tried URLFetch but that was no
good. Any ideas?

I'm new (very new) to Java, but have used Active Server Pages for a
long time now. Is there a way to go to a WebPage (redirect) and send
a parameter of my encrypted data string?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Michael Evans     Answered On: Nov 23

Java is client side, not server  side. You require an ASP method of
encryption. I dont know what to suggest for you.

Java is not able AFAIK to change the URL, perhaps you could use JDBC and
insert the encryption  to a database (via a PK such as a PID), then use
ASP to read it back. Other than that I dont know how to help.

 
Answer #2    Answered By: Woodrow Jones     Answered 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] + " ";
}

 
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: