Link to home
Start Free TrialLog in
Avatar of bonggoy
bonggoy

asked on

Asynchronous Read in ASP

Is there a way to do a SYNCHRONOUS read in ASP?  I want to be able to call another page and wait for it to finish processing, and possibly return me some data, before proceeding with my other task?

Avatar of bonggoy
bonggoy

ASKER

Edited text of question.
Avatar of bonggoy

ASKER

Edited text of question.
Avatar of bonggoy

ASKER

Edited text of question.
Avatar of bonggoy

ASKER

Adjusted points to 150
IIS 4.0 cannot do it, but IIS 5.0 with ASP 3.0 can handle it using "Server.Execute", a new method of the server object. This will do exactly what you're looking for.

Windows 2000 is the way to go for ASP developers - ASP 3.0 handles things in a much more elegant manner, like "Server.Transfer" instead of "Response.Redirect". Much more efficiant code, and on top of that, it runs a bit faster too (in my experience).

You might also look into using w3 Sockets from www.dimac.net. I've heard that with the right use of wrappers, you can kind of do the same thing with that component.

Hope any or all of this helps!

-Aemergin
Check out ASPHttp from ServerObjects.  From the way you worded your question, that sounds like what you are trying to do.

  http://www.serverobjects.com/products.htm#asphttp

Actually, after checking the title of your question I'm unsure now whether you want to do an async or sync read.

Your title says asynchronous, but your question deals with synchronous.

Anywyay, ASPHttp is synchronous.
Avatar of bonggoy

ASKER

sorry it's suppose to be SYNCHRONOUS.  my mistake.
Avatar of bonggoy

ASKER

This question has a deletion request Pending
Avatar of bonggoy

ASKER

I need to be able to do synchronous read in IIS4; IIS5 is for win2k, I don't wan't to use a third party product and no ActiveX control.  If you have any other idea on how to do it, maybe an api call (example code will be great), I would gladly award all my available points.
This question no longer is pending deletion
>>Is there a way to do a SYNCHRONOUS read in ASP?  I want to be able to call another page and wait for it to finish processing, and possibly return me some data, before proceeding with my other task?


Deleting this question after it has been clearly answered seems odd. You asked "Is there a way?" -- you were supplied with three different ways.

And now a fourth answer -- there is no way to do it with an API call in IIS 4.0. You will either have to register a component, install IIS 5.0 (Win2k), or live without the ability to do a synchronous read.

-Aemergin
Avatar of bonggoy

ASKER

I admit that I didn't state what I really wanted.  I am not too fluent in english as it is not my first language and that's the reason for the confusion.  For that I am terribly sorry.

As for your answer of Execute statement in ASP3, I am quite aware of that capability and unfortunately IIS5/ASP3 is not an option owing to win2k.  

As for deleting the question, I don't have any problem awarding points.  It's just that I feel that I did not get the answer I am looking for.  

Again, I will gladly award the points and even give all my points as long as I feel that my question was answered the way I wanted it to be.

In regards to the question, I have basically given up on this approach (sync read on asp), I am now trying to do an DCOM call across the Internet.  That's the reason I am deleting the question.  If this is not the right way of doing it then, I am asking the EE administrator to rollback my request for delete.  I will just wait for the answer I am looking for.

for the fourth suggestion, I am thinking of some sort of socket api calls that i can use.  I could always wrap it up in a COM object and use that COM object from my asp page.  I am also aware of java security (or was it network api) calls wherein you can basically open a socket, send data through it and wait for response.  Right now this is not an option for because of clients requirement.
You explicitly state that you don't want to use an ActiveX component.  But, you then go on to say that you have no problem creating a COM component to wrap the API calls???

What is you're objection to using third-party controls?  If it's cost, you can use Dimac's w3 Socket control-- it's free.  You'll have to hand-code the HTTP request and make a socket call, but it will do what you're asking.

  http://tech.dimac.net/

I don't know why you'd want to re-invent the wheel, but if you want to write wrappers for Winsock API, I guess that's up to you.  You've got the Winsock control and the INetTransfer Control to name just two examples that are much higher abstractions than the API.

If you know java and have J++, it's ridiculously easy to create a COM component using java that does what you need.

You could install ActiveState's perl (http://www.activestate.com) and use perlscript from within your ASP page to pull the other page-- again that's a no-cost solution (perl is free).

There are any number of ways to do what you're asking in your original question, but perhaps I'm not understanding what it is you really want to do.  It sounds like all you want to do is--
 
   1) request a page from within your script
   2) block until the request has returned results
   3) process/filter those results
   4) return something based upon those results

That's easy and can be done with any of the methods I outlined above.  It's basically a one-liner in a perl script.

<% @Language="VBScript" %>
<script language="perlscript" runat="server">
sub getPage {
  use LWP::Simple;
  return get("http://www.somewhere.com/mypage.asp")
}
</script>

<%
  myresults = getPage()
  response.write myresults
%>
Avatar of bonggoy

ASKER

I said I don't want to use ActiveX controls (which to me means .ocx file) and not ActiveX component.  The page needs to run in both Netscape and IE without additional plugin.

I don't want to use third party controls, particularly those coming from a not well established company.  I have nothing againts small company.   It's just that we had several experience before of using really great third party controls and after a few years the company folded up and we ended up rewriting everything the control did when we upgraded our system.

If perlscript is natively supported in IIS4/ASP2 (is it?), I will gladly use that.  I am looking for a solution that won't need me to install third party control/software.  I am open to suggestions, it's just that my decision is basically tied up to the clients requirement.

Avatar of bonggoy

ASKER

I said I don't want to use ActiveX controls (which to me means .ocx file) and not ActiveX component.  The page needs to run in both Netscape and IE without additional plugin.

I don't want to use third party controls, particularly those coming from a not well established company.  I have nothing againts small company.   It's just that we had several experience before of using really great third party controls and after a few years the company folded up and we ended up rewriting everything the control did when we upgraded our system.

If perlscript is natively supported in IIS4/ASP2 (is it?), I will gladly use that.  I am looking for a solution that won't need me to install third party control/software.  I am open to suggestions, it's just that my decision is basically tied up to the clients requirement.

ASKER CERTIFIED SOLUTION
Avatar of clockwatcher
clockwatcher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bonggoy

ASKER

This looks like a good suggestion.  One question though, will there be any effect if there's a form included on the activex dll.  Tradionally, at least in my case, I don't usually include any ui (form, msgbox, etc) in an activex server.  I guess i'm just worried that there will be a drawback or a negative effect.

Lastly, I would like to as much as I wanted to award points to each and everyone who answered my question, unfortunately, there's only one winner.  Anyways thanks to everyone.:)
Avatar of bonggoy

ASKER

I increased the points (all my available points) as I believe you've given an excellent answer.  A very simple yet elegant solution.  Much appreciation.
It's probably not the most efficient way to do things.  But, sometimes simplicity more than makes up for efficiency. ;-)

I don't know of any other real drawbacks.  Like any other piece of VB code it depends upon a number of helper DLLs-- it needs to be packaged up to be installed on a server that doesn't have VB installed.  So distribution can be a bit of a pain, but that's a drawback of VB.

Personally, as I mentioned earlier, the VB solution I posted would probably be one of the last options I'd choose.  If I had to have source code, I'd go for a J++ COM DLL.  Java has built-in support for networking, so it's well suited to do this kind of thing.  Distribution is also much simpler-- if the server is running the latest JVM, you simply have to register the DLL.  The code is almost as simple as using the Internet Transfer Control.  Here's the equivalent in java of the VB code I posted earlier.

/**
 * This class is designed to be packaged with a COM DLL output format.
 * The class has no standard entry points, other than the constructor.
 * Public methods will be exposed as methods on the default COM interface.
 * @com.register ( clsid=612D49A3-D29E-11D3-A3F5-0020E00F5DD9, typelib=612D49A4-D29E-11D3-A3F5-0020E00F5DD9 )
 */
import java.net.*;
import java.io.*;

/**
 * @com.register ( clsid=96CA0A64-D2A0-11D3-A3F5-0020E00F5DD9, typelib=96CA0A63-D2A0-11D3-A3F5-0020E00F5DD9 )
 */
public class GetURL
{

   public String get(String getRequest) {
   
      URL myURL = null;
      try {
        myURL = new URL(getRequest);
      }
      catch (MalformedURLException e) {
        e.printStackTrace();
        return e.toString();
      }
   
      try {
        BufferedReader myReader = new BufferedReader(new InputStreamReader(myURL.openStream()));
        String str;
        String myBuffer = "";
        while ((str = myReader.readLine()) != null) {
           myBuffer += str;
        }
        return myBuffer;
      }
      catch (IOException e) {
        e.printStackTrace();
        return e.toString();
      }
   }
}