khadem1386 Posted May 14, 2007 Share Posted May 14, 2007 hiI have some *.JS file that contain some Mathemathical codes and if or for comman or Function commandhow can i use this java code in asp and server?I know asp have and support java toothanks Link to comment Share on other sites More sharing options...
justsomeguy Posted May 14, 2007 Share Posted May 14, 2007 If you want to run Javascript code in a page, there is a @LANGUAGE directive that goes on the top of the page that tells it which language you are working in. You can only use one language in ASP classic, you cannot mix VBScript and Javascript on the same page, or include pages in one language on another page. Put simply, you cannot redefine @LANGUAGE. Keep in mind that you cannot run .js files as ASP scripts, but you can copy and paste Javascript code into an ASP page, assuming the language on that page is Javascript. Link to comment Share on other sites More sharing options...
khadem1386 Posted May 15, 2007 Author Share Posted May 15, 2007 Thanks for attionsI want make an ASP file with JAVA format.and copy pase all JAVAscripts (a.js) to this asp filethis asp(java) file contain some Functios.in future if I make an ASP file with VB formatand if I use #incolud command for attaching file this ASP(java),can I use its functions in ASP(vb)?thank for your time? Link to comment Share on other sites More sharing options...
aalbetski Posted May 15, 2007 Share Posted May 15, 2007 Actually, you can mix the languages, although this is not recommended as it requires the server to load both run-time librariesThe following examples show two instances of inline script as well as two instances of loading both a .js and .vb script: ")Main ASP page <%@Language=Javasxript%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN"><!--#include file="include.js" --><!--#include file="include.vb" --><% =DoMath(100,100)%><sxript language="vbsxript" runat="server"> Response.Write(DoVBMath(200,200))</sxript><sxript language="javasxript" runat="server"> Response.Write("<br/>Javasxript: ") for (i=1;i<11;i++) { Response.Write(i) Response.Write(" ") }</sxript><sxript language="vbsxript" runat="server"> dim i Response.Write("<br/>VB sxript: ") for i = 11 to 20 Response.Write(i) Response.Write(" ") next</sxript> include.js <%function DoMath(arg1,arg2){ return arg1+arg2}%> include.vb <sxript runat="server" language="vbsxript"> Response.Write("Hello, World (VBsxript)") function DoVBMath(arg1,arg2) DoVBMath = arg1+arg2 end function</sxript> I hope this helps somewhat. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2007 Share Posted May 15, 2007 That's for ASP.NET though, not ASP classic. With ASP classic, you cannot do that (as far as I know). If you have this file: <%@LANGUAGE="VBScript"%>...<!--#include file="inc.asp" --> and it includes this file: <%@LANGUAGE="JavaScript"%>... You will get an error that you cannot redefine @LANGUAGE. I've tried to do this, I have a config file with various variables declared that I wanted to include in files of both languages. The solution was to leave the @LANGUAGE off the include file, and use a syntax that would be legal for both lanuages, that means no comments or things like that. Thankfully Javascript does not require semicolons. Link to comment Share on other sites More sharing options...
aalbetski Posted May 15, 2007 Share Posted May 15, 2007 Thats Classic ASPNote that I did not redefine @Language, simply used script tags with runat="server". This is NOT ASP.NET. It is classic ASP. You were probably confused because you saw runat="server". That syntax has been around long before ASP.NET. Please note that my examples did not include a second @Language as you were implying.And now you know that you CAN do this in classic ASPHere is an example of mixed language usage from w3schools, look at the third item.http://www.w3schools.com/asp/asp_procedures.asp Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2007 Share Posted May 15, 2007 Cool, I didn't realize that ASP classic parsed the script tags, I thought it strictly looked for the <% %> delimiters.So I wonder why you can do that but not redeclare @LANGUAGE. Seems to be the same thing. Link to comment Share on other sites More sharing options...
aalbetski Posted May 15, 2007 Share Posted May 15, 2007 heres another link discussing this in greater detail.http://blogs.msdn.com/ericlippert/archive/...2/19/76438.aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.