November 16, 2002

List of Most Commonly Used CGI Equivalents of Servlets

AUTH_TYPE request.getAuthType()CONTENT_LENGTH request.getContentLength()CONTENT_TYPE request.getContentType()DOCUMENT_ROOT getServletContext().getRealPath()PATH_INFO request.getPathInfo()PATH_TRANSLATED request.getPathTranslated()QUERY_STRING request.getQueryString()REMOTE_ADDR request.getRemoteAddr()REMOTE_HOST request.getRemoteHost()REMOTE_USER request.getRemoteUser()REQUEST_METHOD request.getMethod()SCRIPT_NAME request.getServletPath()SERVER_NAME request.getServerName()SERVER_PORT request.getServerPort()SERVER_PROTOCOL request.getProtocol()SERVER_SOFTWARE getServletContext().getServerInfo() HTTP_XXX_YYY Variables of the form HTTP_HEADER_NAME can be accessed using the request.getHeader(Header-Name) Example: HTTP_REFERER by request.getHeader(“Referer”)HTTP_COOKIE by request.getHeader(“Cookie”)HTTP_USER_AGENT by request.getHeader(“User-Agent”)

A Quick Way to Convert RecordSet to an HTML Table

Public Function GetHtmlString(rs)Dim StrHtmlDim FldLimiter,RowLimiterFldLimiter=””RowLimiter=””If Not rs.EOF ThenStrHtml=”” ‘Table Tag’Prefix for 1 col valueStrHtml=StrHtml & “”StrHtml=StrHtml & rs.GetString(2,-1,FldLimiter,RowLimiter)’Trim of the Last StrHtml=Left(StrHtml,Len(StrHtml)-Len(“”))’Close TableStrHtml=StrHtml & “”End IfEnd Function Usage: Response.Write(GetHtmlString(rs))

Determine the Identity Value of Inserted Row(s)

IN tblTicker table we have following fields: [CompanyID] INT IDENTITY (1,1) [TickerSymbol] [char] (10) NULL [ClassOfShare] [char] (10) NULL We inserted some rows and deleted some from table tblTicker.Now At the time of fresh insertion if we will use the following code we will get the identity value of inserted

Testing the Output Values of a Stored Procedure

This tip is useful when debugging and testing complex stored procedures that have a lot of business logic. It helps to find out exactly what is being returned from a stored procedure.Assume you have a stored procedure: /****** Object: Stored Procedure dbo.sp_DeleteBasketComponents ScriptDate: 30/11/2000 10:40:23 AM ******/CREATE PROCEDURE sp_test(@m_BasketCode varchar(64),@m_Dateout

Delete the Contents of a List

This technique allows you to delete the contents of a List at the same time you are storing pointers a list. This same approach can be used for maps or vectors. #include#includeusing namespace std;//Declaring a class ClassListclass ClassList {public: ClassList() { cout

Pointer to a Constant vs. Constant Pointer

The const keyword in C++ provides a type-safe way to replace some of those #define preprocessor statements that you’re used to writing from C.Whenever you have a value that you do not wish to have changed, you should declare it as const. For example: const int i = 12; //

Initialize STL Containers with Predefined Values

This task is quite common task. However, explicit insertion of values can be unacceptable in many cases?like if you need to insert a lot of values. I’ve found that it’s quite handy to use arrays for this task: pair arr[] ={ pair(“640×480”, 0), pair(“800×600”, 1), pair(“1024×800”, 2), pair(“1280×1024”, 3)};map msi(arr,

Object-construction at a Predetermined Location Using New

When you construct an object using new, you have no control over where it gets created in the heap. What if you want the object to be placed at a specific address? You can do this by using placement syntax in C++. The following example explains how. class sample{private: int

Listening to All AWT Events

For some programs, it is helpful to create a listener to keep track of all the events being dispatched by the UI. This can be very useful in debugging programs. This is a way to listen to all such events in the Java environment. Bascially, you implement AWTEventListener, which listens

No more posts to show