Can I run the crystal reports viewer without browser sessions in classic asp

Greg Watkins
Greg Watkins used Ask the Experts™
on
I have a web application running in classic asp and I am currently using the crystal reports viewer to allow users to generate and download reports. My problem is I need to disable the IIS sessions and switch over to using cookies in order to handle a problem with query overlap on the web application. That is all working fine but the crystal reports viewer pages use sessions. Is there a way to run the crystal reports viewer without using sessions. Below is a sample of one of the crystal reports pages that  generate the reports.

<%@ Language=VBScript %>
<%
Dim Report_Template
Dim basepath, baseVirtualPath, iLen
Dim Param1, Param2, ParamValue2, P2, P2R, ParamValueEndRange2
Dim curValue
Dim viewer
 
basePath = Request.ServerVariables("PATH_TRANSLATED")
While (Right(basePath, 1) <> "\" And Len(basePath) <> 0)
    iLen = Len(basePath) - 1
    basePath = Left(basePath, iLen)
Wend
Response.Write basePath
baseVirtualPath = Request.ServerVariables("PATH_INFO")
While (Right(baseVirtualPath, 1) <> "/" And Len(baseVirtualPath) <> 0)
    iLen = Len(baseVirtualPath) - 1
    baseVirtualPath = Left(baseVirtualPath, iLen)
Wend

If Not IsObject(session("oApp")) Then
    Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
    If Not IsObject(session("oApp")) Then
        response.write "Error:  Could not instantiate the Crystal Reports automation server.  Please check to see that Crystal Reports or ReCrystallize has been properly installed on the web server PC.  See the ReCrystallize Pro Getting Started guide for more information."
        response.end
    End If
End If   
 

If IsObject(session("oRpt")) Then
    set session("oRpt") = nothing
End If

Report_Template = Request("Report_Template")

Set session("oRpt") = session("oApp").OpenReport(basePath & Report_Template, 1)
If Err.Number <> 0 Then
  Response.Write "Error Occurred creating Report Object: " & Err.Description
  Set Session("oRpt") = Nothing
  Set Session("oApp") = Nothing
  Response.End
End If

session("oRpt").DiscardSavedData

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False

 
%>
<!--#include file="reports_connect.asp" -->
<%

set session("ParamCollection") = Session("oRpt").Parameterfields 

set Param1 =  session("ParamCollection").Item(1)
Param1.EnableMultipleValues = 1
For v = 1 To Request("P1").Count
    curValue = Request("P1")(v)
    WriteLog "Debug","member =" & curValue
    If Trim(curValue) <> "" Then
    	If isNumeric(curValue) Then 
    	    Call Param1.AddCurrentValue(CLng(curValue))
    	Else
    		Call Param1.AddCurrentValue(CStr(curValue))
		End If    
    End If
Next

set Param2 =  session("ParamCollection").Item(2)
P2 = Request("P2")
if not IsDate( P2 ) then
    response.write "ReCrystallize Warning:  <BR>"
    response.write P2
    response.write "<BR>"
    response.write "is not a recognizable date value.  Please select a properly formatted date value. <BR>."
    response.end
end if

P2R = Request("P2R")
if not IsDate( P2R ) then
    response.write "ReCrystallize Warning:  <BR>"
    response.write P2R
    response.write "<BR>"
    response.write "is not a recognizable date value.  Please select a properly formatted date value. <BR>."
    response.end
end if
Call Param2.AddCurrentRange( CDate(P2), CDate(P2R), 3 )
If IsObject (session("oPageEngine")) Then                              
	set session("oPageEngine") = nothing
End If

set session("oPageEngine") = session("oRpt").PageEngine

viewer = Request("viewer")
select case viewer
     case "actx"
%>
<HTML>
<HEAD>
<TITLE>
Call History Report
</TITLE>
<meta http-equiv="X-UA-Compatible" content="IE=7">
</HEAD>
<BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript ONLOAD="Page_Initialize" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>
<OBJECT ID="CRViewer"
    CLASSID="CLSID:6F0892F7-0D44-41C3-BF07-7599873FAA04"
    WIDTH=100% HEIGHT=100%
    CODEBASE="/crystalreportviewers115/ActiveXControls/ActiveXViewer.cab#Version=11,5,3,417" VIEWASTEXT>
<PARAM NAME="EnableRefreshButton" VALUE=1>
<PARAM NAME="EnableGroupTree" VALUE=1>
<PARAM NAME="DisplayGroupTree" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=1>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableDrillDown" VALUE=1>
<PARAM NAME="EnableAnimationControl" VALUE=1>
<PARAM NAME="EnableZoomControl" VALUE=1>
<PARAM NAME="EnableSearchControl" VALUE=1>
<PARAM NAME="DisplayToolbar" VALUE=1>
<PARAM NAME="EnableProgressControl" VALUE=1>
<PARAM NAME="EnableStopButton" VALUE=1>
<PARAM NAME="EnableCloseButton" VALUE=1>
<PARAM NAME="EnableNavigationControls" VALUE=1>
<PARAM NAME="PromptOnRefresh" VALUE=0>
<PARAM NAME="EnablePopupMenu" VALUE=1>
<PARAM NAME="DisplayBackgroundEdge" VALUE=1>
<PARAM NAME="DisplayBorder" VALUE=1>
<PARAM NAME="DisplayTabs" VALUE=1>
</OBJECT>

<SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="activate.js"></SCRIPT>

<SCRIPT LANGUAGE="VBScript">
<!--
zoomTimer = window.setInterval("setZoom",250)

Sub setZoom()
 if not CRViewer.IsBusy then
     window.clearInterval(zoomTimer)
     CRViewer.Zoom(100)
 end if
End Sub
Sub Page_Initialize
    On Error Resume Next
    Dim webBroker
    Set webBroker = CreateObject("CrystalReports115.WebReportBroker.1")
    if ScriptEngineMajorVersion < 2 then
        window.alert "Internet Explorer 3.02 users running Windows NT 4 should get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users running Windows 95 need DCOM95 and the latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site."
        CRViewer.ReportName = Location.Protocol + "//" + Location.Host + <% response.write( chr(34) & baseVirtualPath & chr(34)) %> + "rptserver.asp"
    else
        Dim webSource
        Set webSource = CreateObject("CrystalReports115.WebReportSource.1")
        webSource.ReportSource = webBroker
        webSource.URL = Location.Protocol + "//" + Location.Host + <% response.write( chr(34) & baseVirtualPath & chr(34)) %> + "rptserver.asp"
        webSource.PromptOnRefresh = False
        CRViewer.ReportSource = webSource
    end if
    CRViewer.ViewReport
End Sub
-->
</SCRIPT>
<OBJECT ID="ReportSource"
    CLASSID="CLSID:84D35B77-75B4-4ff0-A2DE-6ED1B3EBE036"
    HEIGHT=1% WIDTH=1%
    CODEBASE="/crystalreportviewers115/ActiveXControls/ActiveXViewer.cab#Version=11,5,3,417">
</OBJECT>
<OBJECT ID="ViewHELP"
    CLASSID="CLSID:9FD60A56-0184-4886-88A7-9943FB0DF9EA"
    HEIGHT=1% WIDTH=1%
    CODEBASE="/crystalreportviewers115/ActiveXControls/ActiveXViewer.cab#Version=11,5,3,417">
</OBJECT>
<div>
</div>

</BODY>
</HTML>
<% case "java" %>
<html>
<head>
<title>
Call Report
</title>
</head>
<body bgcolor=C6C6C6>
<P align="center">
<object
 classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
 width=100%
 height=100%
 codebase="/crystalreportviewers115/JavaPlugIn/Win32/j2re-1_4_2_04-windows-i586-p.exe">
<param name=type value="application/x-java-applet;version=1.4.2">
<param name=code value="com.crystaldecisions.ReportViewer.ReportViewer">
<param name=codebase value="/crystalreportviewers115/javaviewer/">
<param name=archive value="ReportViewer.jar">
<param name=Language value="en">
<param name=ReportName value="rptserver.asp">
<param name=ReportParameter value="">
<param name=HasGroupTree value="true">
<param name=ShowGroupTree value="true">
<param name=HasRefreshButton value="true">
<param name=HasPrintButton value="true">
<param name=HasExportButton value="true">
<param name=HasTextSearchControls value="true">
<param name=CanDrillDown value="true">
<param name=HasZoomControl value="true">
<param name=PromptOnRefresh value="true">
<comment>
<embed
 width=100%
 height=100%
 type="application/x-java-applet;jpi-version=1.4.2"
 pluginspage="/crystalreportviewers115/JavaPlugin/Win32/j2re-1_4_2_04-windows-i586-p.exe"
 java_code="com.crystaldecisions.ReportViewer.ReportViewer"
 java_codebase="/crystalreportviewers115/javaviewer/"
 java_archive="ReportViewer.jar"
Language="en"
ReportName="rptserver.asp"
ReportParameter=""
HasGroupTree="true"
ShowGroupTree="true"
HasRefreshButton="true"
HasPrintButton="true"
HasExportButton="true"
HasTextSearchControls="true"
CanDrillDown="true"
HasZoomControl="true"
PromptOnRefresh="true"
></embed>
</comment>
</object>
</p>
</body>
</html>
<%
case "HTML"
	response.redirect "htmstart.asp"

case "Word", "Excel", "RTF", "PDF"

	if viewer = "Text" then
	    exportfmt = "crxf_txt:0"
	    exportext = ".txt"
	end if
	if viewer = "Word" then
	    exportfmt = "crxf_wordw:0"
	    exportext = ".doc"
	end if
	if viewer = "Excel" then
	    exportfmt = "crxf_xls:0"
	    exportext = ".xls"
	end if
	if viewer = "ExcelData" then
	    exportfmt = "crxf_xls:10"
	    exportext = ".xls"
	end if
	if viewer = "RTF" then
	    exportfmt = "crxf_rtf:0"
	    exportext = ".rtf"
	end if
	if viewer = "EditableRTF" then
	    exportfmt = "crxf_rtf:39"
	    exportext = ".rtf"
	end if
	if viewer = "PDF" then
	    exportfmt = "crxf_pdf:0"
	    exportext = ".pdf"
	end if

	Response.Clear
	Response.Redirect "rptserver.asp?cmd=export&export_fmt=" & exportfmt & "&exportfilename=Call_Report" & exportext

End Select %>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Not that I know of.  That is how they control licensing.

mlmcc
I have found a solution. I setup the report viewer as a separate web application with sessions enabled and my web app points to the report viewer app to generate and view the reports.

Thanks for the quick reply though.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Not a web programmer so I don't know about those methods.

Glad you found a solution

mlmcc

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial