用 ASP 檔案來調用 Servlet

來源:互聯網
上載者:User
在 WebSphere應用伺服器 中的 ASP 支援包括一個用於嵌入 Servlet 的 ActiveX 控制,下面介紹ActiveX 控制AspToServlet 的方法和屬性。
該方法說明如下:

(1) String ExecServletToString(String servletName);執行 ServletName,並將其輸出返回到一個字串中。

(2) ExecServlet(String servletName);執行 ServletName,並將其輸出直接發送至 HTML 頁面。

(3) String VarValue(String varName);獲得一預置變數值(其它格式)。

(4) VarValue(String varName, String newVal);設定變數值。變數佔據的總大小應小於 0.5 個千字
節(Kbyte)。且僅對設定檔使用這些變數。
其屬性如下:
= Boolean WriteHeaders;若該屬性為真,則 Servlet 提供的標題被寫入使用者處。預設值為假。
= Boolean OnTest;若該屬性為真,伺服器會將訊息記錄到產生的 HTML 頁面中。預設值為假。
下列ASP 指令碼樣本是以 Microsoft Visual Basic Scripting(VBScript)書寫的。
〈%
´ Small sample asp file to show the capabilities of the servlets and the ASP GateWay ...
%>
〈H1> Starting the ASP->Java Servlet demo〈/H1>
〈%
´ Create a Servlet gateway object and initialize it ...
Set javaasp = Server.CreateObject("AspToServlet.AspToServlet")
´ Setting these properties is only for the sake of demo.
´ These are the default values ...
javaasp.OnTest = False
javaasp.WriteHeaders = False
´ Add several variables ...
javaasp.VarValue("gal") = "lag"
javaasp.VarValue("pico")= "ocip"
javaasp.VarValue("tal") = "lat"
javaasp.VarValue("paz") = "zap"
javaasp.VarValue("variable name with spaces") = "variable value with spaces"
%>
〈BR>
Lets check the variables
〈%
Response.Write("variable gal = ")
Response.Write(javaasp.VarValue("gal"))
%>
〈BR>
〈%
Response.Write("variable pico = " & javaasp.VarValue("pico"))
%>

〈BR>
〈HR>
〈%
galout = javaasp.ExecServletToString("SnoopServlet")
If javaasp.WriteHeaders = True Then
%>
Headers were written 〈%
Else
%>
Headers were not written 〈%
End If
Response.Write(galout)
%>
〈H1> The End ...〈/H1>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.