Solved

Response.Redirect if Application.Lock() is in use

Posted on 2004-04-06
4
413 Views
Last Modified: 2012-05-04
I have a page which locks the application it contains. (Page's code is below) What I need to do is have the code check to see if the application is running, or, if the Application.Lock() has been applied (if possible). If so, I would like to use a Response.Redirect to output to another page. (Let's say 403.htm, for the sake of this issue)

Here is the code:

<%
Application.Lock()
Tag = Request("Tag")
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
IP = Request.Form("Target")
if Request("vbOption") = "no"  then
RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIX.cmd " & Tag & " " & "DEV " & FileName, 1, True)
else
RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIXVB.cmd " & Tag & " " & "DEV " & FileName, 1, True)
end if
Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt", 1)
TextBuffer = TextFile.ReadAll
if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
buildsuccess="BUILD SUCCESSFUL"
else
buildsuccess="BUILD FAILED"
End If
For i = 1 to Len(TextBuffer)
If Mid(TextBuffer,i,1) = chr(13) Then
Response.Write("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
FileSys.DeleteFile "d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt"
Application.Unlock()
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
      {
      answer = confirm("Build SUCCESSFUL, Deploy to Development?");

      if (answer !=0)
            {
            location = "/spirituality561/devdeployUNIX.asp?Tag=<%=Tag%>";
            }
      }
</script>

<%if buildsuccess="BUILD SUCCESSFUL" then%>
<script>
buildSuccessful();
</script>
<%end if%>

0
Comment
Question by:boucherc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
ap_sajith earned 125 total points
ID: 10773089
Try something like...

<%
If Application("IsLocked")=1 Then
      Response.Redirect "Page.asp?err=true"
Else
      Application.Lock()
      Application("IsLocked")=1
      Tag = Request("Tag")
      Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
      FileName = FileSys.GetTempName
      Set WShShell = Server.CreateObject("WScript.Shell")
      IP = Request.Form("Target")
      if Request("vbOption") = "no"  then
      RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIX.cmd " & Tag & " " & "DEV " & FileName, 1, True)
      else
      RetCode = WShShell.Run("d:\CodeRelease\spirituality561\CVSRoot\callantbuildUNIXVB.cmd " & Tag & " " & "DEV " & FileName, 1, True)
      end if
      Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt", 1)
      TextBuffer = TextFile.ReadAll
      if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
      buildsuccess="BUILD SUCCESSFUL"
      else
      buildsuccess="BUILD FAILED"
      End If
      For i = 1 to Len(TextBuffer)
      If Mid(TextBuffer,i,1) = chr(13) Then
      Response.Write("<BR>")
      else
      Response.Write(Mid(TextBuffer,i,1))
      end if
      Next
      TextFile.Close
      FileSys.DeleteFile "d:\CodeRelease\spirituality561\CVSRoot\" & FileName & ".txt"
      Application("IsLocked")=0
      Application.Unlock()
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
     {
     answer = confirm("Build SUCCESSFUL, Deploy to Development?");

     if (answer !=0)
          {
          location = "/spirituality561/devdeployUNIX.asp?Tag=<%=Tag%>";
          }
     }
</script>

      <%if buildsuccess="BUILD SUCCESSFUL" then%>
            <script>
            buildSuccessful();
            </script>
      <%
      end if
End If 'If Application("IsLocked")=1 Then
%>


Cheers!!
0
 

Author Comment

by:boucherc
ID: 10774290
The above will lock the application, as it had before, but will not run the redirect.

A subsequent request of the application will "queue up" and run after the lock is released from the first request, instead of redirecting to the Response.Redirect page.
0
 

Author Comment

by:boucherc
ID: 10776437
I'm not sure if it makes a difference, but this page also has html code within it. Below what I tried to set up and whereever I placed the Redirect, it would not work:

<%
If Application("mbeBuild")=1 Then
Response.Redirect "/403_9.htm"
Else
%>

<html>

<body bgcolor="#000080" text="#FFFFFF" link="#FFFFFF" vlink="#FFFF9C" alink="#FFFFFF" background="bg.jpg" bgproperties="fixed">
<%
Application.Lock()
Application("mbeBuild")=1
Tag = Request("Tag")
Set FileSys = Server.CreateObject("Scripting.FileSystemObject")
FileName = FileSys.GetTempName
Set WShShell = Server.CreateObject("WScript.Shell")
IP = Request.Form("Target")
if Request("vbOption") = "no"  then
RetCode = WShShell.Run("d:\CodeRelease\mbelbh561\CVSRoot\callantbuild.cmd " & Tag & " " & "STAGING " & FileName, 1, True)
else
RetCode = WShShell.Run("d:\CodeRelease\mbelbh561\CVSRoot\callantbuildVB.cmd " & Tag & " " & "STAGING " & FileName, 1, True)
end if
Set TextFile = FileSys.OpenTextFile("d:\CodeRelease\mbelbh561\CVSRoot\" & FileName & ".txt", 1)
TextBuffer = TextFile.ReadAll
if instr(textbuffer,"BUILD SUCCESSFUL")>0 then
buildsuccess="BUILD SUCCESSFUL"
else
buildsuccess="BUILD FAILED"
End If
For i = 1 to Len(TextBuffer)
If Mid(TextBuffer,i,1) = chr(13) Then
Response.Write("<BR>")
else
Response.Write(Mid(TextBuffer,i,1))
end if
Next
TextFile.Close
FileSys.DeleteFile "d:\CodeRelease\mbelbh561\CVSRoot\" & FileName & ".txt"
%>
<TITLE><%=buildsuccess%></TITLE>
<BR><BR>
<CENTER>

<script>
function buildSuccessful()
      {
      answer = confirm("Build SUCCESSFUL, Deploy to Staging?");

      if (answer !=0)
            {
            location = "/mbelbh561/admins/stagedeploy.asp?Tag=<%=Tag%>";
            }
      }
</script>

<%if buildsuccess="BUILD SUCCESSFUL" then%>
<script>
buildSuccessful();
</script>
<%end if%>

<BR>
<A HREF=http://WEBCODE-P:81>-=HOME=-</A>
</CENTER>

<%
Application("mbeBuild")=0
Application.Unlock()
%>

</body>

</html>

<%
End If
%>
0
 

Author Comment

by:boucherc
ID: 10777548
I was able to get this to work by setting the Application to 1 before locking it:

<%
If Application("mbeBuild")=1 Then
Response.Redirect "/403_9.htm"
Else
Application("mbeBuild")=1
End If
%>

<html>

<body bgcolor="#000080" text="#FFFFFF" link="#FFFFFF" vlink="#FFFF9C" alink="#FFFFFF" background="bg.jpg" bgproperties="fixed">
<%
Application.Lock()

Since I ws pointed in the right direction, I will award the points.

Thanks for your help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
rebind a grid after user clicks on node in treeview 1 48
IIS components 2 31
Debugging Html 8 31
Display field if column exists 7 33
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question