December 5, 2000

Testing for Closed Socket

Question: Is there any way to test if a socket is still open without writing to it? Answer: Despite being relatively easy to use, the Socket class is not implemented as well as it might have been. Connections are established at the time the Socket is created, so there is

Updating HTTP Headers

Question: In the first servlet we set the value for HTTP header as below: response.setHeader(“SessionKey”,”SessionValue”); In the next servlet we tried retrieving the above set header value as: request.getHeader(“SessionKey”); We are getting null as output of getHeader. How can we get the HTTP header set in first servlet, in second

Estimate Your Web Document’s Printed Size

There are times when you’d like to know a little bit about how your Web page will print. For example, if you are dynamically generating reports, you can put a button on the page that calls window.print() to print the page. However, you might end up with a 500-page document

Use a VB Label as a Web Link

I like the idea of clicking on a VB label that looks like a Web anchor and pops up the Web browser pointing the user to the page. Here is how I would implement it: Set the label’s caption to

Union Structure in Visual Basic

When using C++, the Union enables programmers to look at the same memory area from different perspectives. The same is possible in Visual BASIC. There is an LSET statement that allows two variables to be overlapped in the same memory area. Private Type MyType1 x as Integer y as Integer

Sort The Contents of an Array

Private Sub BubbleSort(varArray As Variant, bAscending As Boolean) ‘Option Base 0 is assumed Dim HoldEntry As Integer Dim SwapOccurred As Boolean Dim iItteration As Integer Dim i As Integer SwapOccurred = True iItteration = 1 Do Until Not SwapOccurred SwapOccurred = False For i = LBound(varArray) To UBound(varArray) – iItteration

Null Handling in VB6

A simple way to get around having to handle Nulls in fields from recordset is to concatenate a zero length string at the end of the field value, as illustrated in the following example: txtCustomer.text = rst.Fields(

Validate Text to Numeric

Public Function ValidateTextToNumeric(ctlToValidate As TextBox)’**********************************’This function tests the validation’for Numeric value of a given text’**********************************Dim strTextToValidate As StringDim blnNumericValid As BooleanstrTextToValidate = ctlToValidate.Text’*** Validation would be TRUE, in all the below cases ***blnNumericValid = CBool(strTextToValidate =

Tracking Session Information When Cookie Is Disabled

What is the simplest way to keep track of session information if the cookie is disabled in the client? Even though we have other alternative solutions like passing the session ID in the query string or passing the session ID through a hidden variable, the simplest way is to encode

No more posts to show