?
Solved

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

Posted on 2004-04-06
4
Medium Priority
?
423 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 375 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 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