Solved

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

Posted on 2004-04-06
4
405 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now