Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I put java code into a component? 1

Status
Not open for further replies.

rtgordon

Programmer
Jan 17, 2001
104
US
I have an ASP page that calls a java program (class file in C:\winnt\java\trustlib) and I was wondering if making a component out of this code would improve performance. If so, where can I get a tootorial on how to accomplish this.

gordon
 
Great info! Is there any reason to think that running the application like this will be more efficient (faster) than I currently have it setup? i have an MQSeries transaction that queries a mainframe and populates an asp page with the results. It runs in the 3-5 second range, and I am looking at improving performance.

tia
gordon
 
Honestly, from what I've read no. Since you already have the program in your trusted library, there shouldn't be too much of an improvement if you compile it into a DLL.

The only reason you would want to compile it into a DLL is so that MTS can take advantage of it. Again, this depends on your situation, but if you think that the MTS object pooling can benefit you, then maybe you should consider creating it into a COM object.

By populating an ASP page, are you populating an ASP recordset, or directly outputting the contents onscreen from your component? Since I think that you can only populate a recordset set from the trusted library (not sure) - you might want to consider making a DLL so that you can access the intrinsic ASP objects (Response, Request, etc). This way, you can output the whole page from your DLL, easily cutting your runtime down.

Since J++ is pretty much being turned obsolete by Microsoft (see all the Sun v MS court cases and the development of C#), I wouldn't suggest getting too comfortable creating ASP COM from J++....

just my thoughts. ignore them freely :)
leo leo
 
The class file in the trusted library is returning a 1000 character text string. I am essentially mapping out each of the fixed width fields into ASP variables using mid and painting the page with them. Could there possibly be a better approach? I don't quite see where a recordset fits into this picture.

gordon
 
hm.

since you are doing the string processing with Java, that's a whole lot better solution than doing it with VBScript (since it's extremely slow).

The 1000 character text file is getting split up into various fields, then you are outputting them on screen? If that's the case, then you probably have the most efficient solution implemented. But, if you are passing the split up text back to VBScript, then making VBScript paint the page, then maybe you might want to consider making it into a DLL. With the DLL, the only thing that you would need to do on the ASP page is create the object and destroy the object. You can then have your DLL do all the Response.writes to output the page.

I don't know if a RS fits your scenario either, sicne it seems like you have N amount of unrelated variables that you are outputting on screen.

hth
leo leo
 
ahh, but I am not doing the string processing in java. Maybe that is where I should look. I send the asp page a 1000 byte string, and I populate the ASP variables like so:

ResaleQtyBrk1 = mid(strResult,466,6)
ResalePrice1 = mid(strResult,472,9)
ResaleQtyBrk2 = mid(strResult,481,6)
ResalePrice2 = mid(strResult,487,9)

Then I paint the page like so:

<tr width=150 bgcolor=#9999FF>
<td width=100 align=left><b><%=ResaleQtyBrk1%>  </b></td>
<td width=50 align=left><%=ResalePrice1%></td>
</tr>
<tr width=200 bgcolor=#9999FF>
<td width=100 align=left><b><%=ResaleQtyBrk2%>  </b></td>
<td width=50 align=left><%=ResalePrice2%></td>
</tr>

I understand your point about putting the parsing/painting logic into a component. That may improve things. As far as processing the string in java, I would have to do more research. The only way that I see how to do it (using ASP anyway) is pass one variable back with a return like so:

return msgTxt;

Thanks for the responses!

gordon
 
The return(var); is how our java code here works too... but that isn't the only way that you need to do it.

Consider making a Java DLL, and breaking up the string in your Java DLL. From your Java DLL, I think that if you create public global variables, you can access those as properties (I'm not sure, and our Java programmer isn't here today, but it seems to make sense). Thinking in this way, by creating the J++ DLL, your ASP page would break down into something like this:

I assume you pass parameters into a function (myFunction), to create the prices that you need.

...
dim obj
set obj = server.createobject(&quot;myJPP.ComObj&quot;)
obj.myFunction(param1,param2,param3)
%>
<tr width=150 bgcolor=#9999FF>
<td width=100 align=left><b><%=obj.ResaleQtyBrk1%> </b></td>
<td width=50 align=left><%=obj.ResalePrice1%></td>
</tr>
<tr width=200 bgcolor=#9999FF>
<td width=100 align=left><b><%=obj.ResaleQtyBrk2%> </b></td>
<td width=50 align=left><%=obj.ResalePrice2%></td>
</tr>
<%
set obj = nothing

hth a little a least
leo leo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top