473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Visual Basic Response.BinaryWrite to finish in the OutputStream

I am using Visual Basic to dynamically create a Visio diagram. It is called from a web application.

The web app makes the call to the .aspx file, which does its work and then writes the file to the web app through Response.BinaryWrite.

The problem is this: there could be multiple users on the web app, and the VB app is currently confusing the web app with simultaneous use. That is, if two users both make a call to the VB app, the VB app doesn't separate the output, so one user gets a binary file (unreadable by Visio) with both users' contents, and the other user gets a blank Visio file.

Can I use anything in the Response.AddHeader to distinguish the output so the Java code for the app can pick the correct output?
Jul 29 '10 #1
2 4390
Joseph Martell
198 Expert 128KB
I'm not sure I completely understand your scenario, but if you are just looking for a unique token to pass through your processing for each call then you could try using a GUID.
Jul 29 '10 #2
@jbm1313
User A and User B both click a link in a web app. The link is dynamically generated in the form of:

http://servername/VisioDrawingServic...e.aspx?PID=777

A java class in the web app creates a java.net.URLConnection with the url from the link. Then, it creates a BufferedInputStream object to read the response from the VB app.

The VB app creates a FileData.vb object:

Expand|Select|Wrap|Line Numbers
  1. Public Class FileData
  2.     Private _name As String
  3.     Private _mimeType As String
  4.     Private _data As Byte()
  5.  
  6.     Public Property Name() As String
  7.         Get
  8.             Return _name
  9.         End Get
  10.         Set(ByVal Value As String)
  11.             _name = Value
  12.         End Set
  13.     End Property
  14.  
  15.     Public Property MimeType() As String
  16.         Get
  17.             Return _mimeType
  18.         End Get
  19.         Set(ByVal Value As String)
  20.             _mimeType = Value
  21.         End Set
  22.     End Property
  23.  
  24.     Public Property Data() As Byte()
  25.         Get
  26.             Return _data
  27.         End Get
  28.         Set(ByVal Value As Byte())
  29.             _data = Value
  30.         End Set
  31.     End Property
  32.  
  33. End Class
  34.  
Then, it reads from a database prompted by the "PID" query string, and creates a Visio diagram that is assigned as an array of bytes in a FileData object named diagrams.

Expand|Select|Wrap|Line Numbers
  1.         Dim diagrams() As FileData
  2.  
  3.         diagrams = Diagram.Request(intPID, intLID, Not boolGetPdf, boolGetPdf, True, namesExist)
  4.  
  5.         If diagrams.Length > 0 And Response.IsClientConnected Then
  6.  
  7.             If boolGetPdf Then
  8.                 Response.ContentType = "application/pdf"
  9.             Else
  10.                 Response.ContentType = "application/x-visio"
  11.             End If
  12.  
  13.             Response.AppendHeader("Content-Disposition", "attachment; filename=""" & diagrams(0).Name & """")
  14.             Response.AppendHeader("Content-Length", "" & diagrams(0).Data.GetLength(0))     ' Set content length
  15.  
  16.             Response.BinaryWrite(diagrams(0).Data)
  17.         Else
  18.             ' Nothing To Do
  19.             Response.Write("No data returned from request")
  20.         End If
  21.  
  22.         Response.Flush()
  23.         Response.End()
  24.  
The VB app creates two instances of Visio.exe, 1 for A and 1 for B.

The VB app then writes this back to the java class that called the URLConnection. The java class reads the byte data from the BufferedInputStream, and writes it to the response of the web app with response.getOutputStream().write(data, 0, length), where data is an array of bytes (byte[]) and length is the return value of BufferedInputStream.read(data).

Whoever is "done" first and clicks on the "Open/Save" dialog box first gets a binary file that is twice as big as it's supposed to be that cannot be opened by Visio, and the loser gets a blank Visio document.

I have been researching, reading, and studying some way to make one of these two processes more choosy. Ideally, the java class would only accept byte data in the output stream from the "correct" source, but how does the VB app distinguish the byte data in the OutputStream? I would think that Response.BinaryWrite would be unique to a specific http response, instead of just dumping it to one static outputstream that's available to anyone listening/requesting.

Any help or insight is appreciated!
Jul 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: katrinaVictim | last post by:
Question: I get the eror listed at the bottom of the post. What can I do to make the response of the x1.send a "binary" type? Or, in general, how can I just "make this work"? <%@...
1
by: Charlie | last post by:
Hi: I'm uploading documents into a SQL Server Image field and using Response.BinaryWrite() to download or view them in the browser. Some doc types like Adobe Illustrator and Photoshop files...
2
by: jhansl | last post by:
Hello, I am trying desperately how to find out if the bytes sent in a Response.BinaryWrite (or bytes written to Response.OutputStream) are ACTUALLY sent to the client. My problem is that I have...
2
by: PrePort | last post by:
The goal here is to return a dynamic image from an HttpHandler that I have written. 2 questions 1. I am reading the images into byte fine and cacheing them fine, but what should I use to deliver...
5
by: Katie | last post by:
Hi, I made a posting a while ago regarding doing a binarywrite of a large file in chunks and got a lot of helpful responses. I was able to make it work then. Unfortunately when the project is...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
5
by: twiggy182 | last post by:
Hi, I really need you help because I'm not very familliar with ASP and I could not find any solution to my problem. To put you in situation, I have a CGI to which I send a file name, and that...
1
by: mattridings | last post by:
Hi gang, Have a script that works fine. However, it's really cpu intensive and I'm looking for suggestions on a) whether or not that's normal and if so b)a better way of doing it. Script is...
1
by: Chris Ashley | last post by:
I have a stream of bytes (making up a large file) coming from somewhere, and need to send it to the user. I can't send it to Response.OutputStream because this is read only, and storing the entire...
14
by: S N | last post by:
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client. Kindly indicate the maximum size of the file that can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.