473,381 Members | 1,463 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,381 software developers and data experts.

ASP VBScript JScript confusion

I dont know where to start my question so let me tell you my story :)

The ASP that cause me trouble is running on IIS that set ASP default language to JScript instead of VBScript.

This ASP page is popped up by another ASP page and there are authentication, privilege and security stuff involved. And yes this page contain a lot of javascript.

there is a <DIV></DIV> in this page for me. And my job is as simple as put another page between that tag.

Yes it's that easy. It like ... I love your web site and I want to show your homepage of your website in the middle of my page.

and I found this script on the internet

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Private Function GetWebPage(ByVal HTTPAddress, ByVal CharSet)
  3.     Dim strContent, xml_http, strBody, strText, max
  4.     '--- Fetch the web page
  5.     On error resume next
  6.     Set xml_http = Server.CreateObject("Microsoft.XMLHTTP")
  7.         xml_http.Open "GET", HTTPAddress, False
  8.         xml_http.Send
  9.         If Err Then
  10.             GetWebPage = ""
  11.             Exit Function
  12.         End If
  13.         strContent = xml_http.responseBody
  14.     Set xml_http = Nothing
  15.     On Error GoTo 0
  16.     '--- Converts the binary content to text
  17.       '--- Create Stream object
  18.       Dim BinaryStream
  19.       Set BinaryStream = CreateObject("ADODB.Stream")
  20.       '--- Specify stream type - we want To save text/string data.
  21.       BinaryStream.Type = 1
  22.       '--- Open the stream And write text/string data To the object
  23.       BinaryStream.Open
  24.       BinaryStream.Write strContent
  25.       '--- Change stream type To binary
  26.       BinaryStream.Position = 0
  27.       BinaryStream.Type = 2
  28.       '--- Specify charset For the source text (unicode) data.
  29.       If Len(CharSet) > 0 Then
  30.         BinaryStream.CharSet = CharSet
  31.       Else
  32.         BinaryStream.CharSet = "UTF-8"
  33.       End If
  34.       '--- Open the stream And get binary data from the object
  35.       strText = BinaryStream.ReadText
  36.         '--- remove headers
  37.         max = InStr(1, strText, Chr(10) & Chr(10), 1)
  38.         GetWebPage = Mid(strText, max + 1)
  39. End Function
  40. Dim strPage
  41. strPage = GetWebPage( "http://www.livio.net/main/default.asp", "" )
  42.  '--- get the html source of the livio.net home page and store it into the variable strPage.
  43. Response.Write (strPage)
  44. %>
  45. <html>
  46. <body>
  47. </body>
  48. </html>
it works fine by itself. But I can not put this in my code because my page use JScript

I found another script on another website that help me use both jscript and vbscript using 2 .asp

the first asp is page1.asp

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <title>My page</title>
  3. <body>
  4. <script language="javascript" src="page2.asp"></script> 
  5. </body>
  6. </html>

the secondpage asp is page2.asp

Expand|Select|Wrap|Line Numbers
  1. <%@ language="VBScript"%>
  2. <%
  3. strPage = "Hello"
  4. %>
  5. document . write ("<%=strPage%>")
this also work fine.

So I tried to put the first script I found in the first website in the page2.asp like this

Expand|Select|Wrap|Line Numbers
  1. <%@ language="VBScript"%>
  2. <%
  3. Private Function GetWebPage(ByVal HTTPAddress, ByVal CharSet)
  4.     Dim strContent, xml_http, strBody, strText, max
  5.     '--- Fetch the web page
  6.     On error resume next
  7.     Set xml_http = Server.CreateObject("Microsoft.XMLHTTP")
  8.         xml_http.Open "GET", HTTPAddress, False
  9.         xml_http.Send
  10.         If Err Then
  11.             GetWebPage = ""
  12.             Exit Function
  13.         End If
  14.         strContent = xml_http.responseBody
  15.     Set xml_http = Nothing
  16.     On Error GoTo 0
  17.     '--- Converts the binary content to text
  18.       '--- Create Stream object
  19.       Dim BinaryStream
  20.       Set BinaryStream = CreateObject("ADODB.Stream")
  21.       '--- Specify stream type - we want To save text/string data.
  22.       BinaryStream.Type = 1
  23.       '--- Open the stream And write text/string data To the object
  24.       BinaryStream.Open
  25.       BinaryStream.Write strContent
  26.       '--- Change stream type To binary
  27.       BinaryStream.Position = 0
  28.       BinaryStream.Type = 2
  29.       '--- Specify charset For the source text (unicode) data.
  30.       If Len(CharSet) > 0 Then
  31.         BinaryStream.CharSet = CharSet
  32.       Else
  33.         BinaryStream.CharSet = "UTF-8"
  34.       End If
  35.       '--- Open the stream And get binary data from the object
  36.       strText = BinaryStream.ReadText
  37.         '--- remove headers
  38.         max = InStr(1, strText, Chr(10) & Chr(10), 1)
  39.         GetWebPage = Mid(strText, max + 1)
  40. End Function
  41. Dim strPage
  42. strPage = GetWebPage( "http://www.livio.net/main/default.asp", "" )
  43.  '--- get the html source of the livio.net home page and store it into the variable strPage.
  44. 'Response.Write (strPage)
  45. %>
  47. document . write ("<%=strPage%>")
it doesn't work.

I tried to use Response.write it doesn't work too.

so I tried a fews other things too.

1. after statement
strPage = GetWebPage( "http://www.livio.net/main/default.asp", "" )

I tried
strPage = Len(strPage)
and it show a number on my page then I think this is not far from the answer.

I tried
strPage = Mid(strPage, 100, 10)

and it show some string on my page

I found out that in fact this strPage is a string that have a lot of double quote in it and that seem to be a lot of trouble for document . write

so my question are

1. Why Response.Write (strPage) did not work in this case?
2. document . write ("<%=strPage%>") seem to work with out double quote, how ca i fix it?
3. Is there other ways to do this?
Apr 11 '07 #1
2 4539
Hi tunk!

There's a very simple solution to this problem...
at first; just forget use of any ADODB ~ objects
You can get the binary data outright from the XML object
in the following way...
Expand|Select|Wrap|Line Numbers
  1.        Dim xml_http, bStr, strContent
  2.        Set xml_http = Server.CreateObject("Microsoft.XMLHTTP")
  4.        'use POST method for large amount of data
  5.         xml_http.Open "GET", HTTPAddress, False
  6.         xml_http.Send
  8.        ' your error-handling thing
  9.        '....        
  11.         bStr = xml_http.responseBody
  12.         Set xml_http = Nothing
  14.        For i = 1 to LenB(bStr)
  15.         strContent = strContent & Chr(AscB(MidB(bStr, i, 1)))
  16.       Next
  18.       Response.Write(strContent)
' and that's all

I hope you can find this useful

Oct 28 '07 #2
Hi again tunk!

one more little thing...

'add the following line next the .send command


Oct 29 '07 #3

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

Similar topics

by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
by: Laser Lu | last post by:
In ASP and CGI, which one would be executed more fast and has the better execution efficiency in IIS? And how about writing CGI in VB? -- Best regards, Laser Lu
by: Christopher Brandsdal | last post by:
Hi! Maby this is wring newsgroup.. I'm using ASP / VBscript on my own cms system, but I needed to use some jscript to make something work... I'm new to jscript, so here is a simple question:...
by: Mike Schinkel | last post by:
Does anyone know if there are bugs in VBScript's GetRef()? I'm using VBScript Version 5.6.8515 on Win2003Server w/ASP. Sometimes it returns an object that VarType() says is a vbObject. Other...
by: gpence | last post by:
!!! Newbie question warning !!! I am somewhat familiar with javascript's ability to "access" the browser's favorites list -- for example, using window.home() will take you to the default URL --...
by: joe | last post by:
I am having problems checking for the value of an XMLDOM object . Lets say my XMLDOM object was successfully created as objXMLDoc, and that has several nodes on it. In the case of a VBScript loop...
by: dkiernan | last post by:
I am stumped. I have several websites running on a 2003 IIS6 box, all running basically the same code (each site has its own home directory and copy of the code). All are running in the same App...
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.