HttpServletRequest2 interface
This interface extends the standard javax.servlet.http.HttpServletRequest interface.
Although anyone developing an application for NAS can use HttpServletRequest2, this interface is typically used in components generated by Netscape Application Builder. HttpServletRequest2 provides methods for handling servlet errors, as well as providing additional support for servlets.
One method in particular, the getAppLogic( ) method, is useful to developers outside the NAB environment. Through the getAppLogic( ) method, the HttpServletRequest2 interface supports servlet access to AppLogics, allowing applications to call methods on AppLogics.
Package
com.netscape.server.servlet.extension
Methods
Related Topics
IServletErrorHandler interface,
Taking Advantage of NAS Features
convertITemplateDataToResultSet( )
Creates a ResultSet wrapper for an ITemplateData object.
Syntax
public static ResultSet convertITemplateDataToResultSet(
String groupName,
ITemplateData templateData)
groupName.
The group name of the specified ITemplateData.
templateData.
The ITemplateData to be wrapped.
Usage
The convertITemplateDataToResultSet( ) method takes an ITemplateData object and wraps it so that it conforms to the specifications of a JDBC ResultSet object.
Use this method only if you have HTML templates that were developed for a previous version of NAS, and you want to run them in the JSP engine.
Rules
Hierarchical ITemplateData objects are not supported, so do not specify one as a parameter.
Return Value
A ResultSet object.
dispatchAction( )
Calls a method corresponding to a form-action in a servlet.
Syntax
public abstract int dispatchAction(
HttpServletResponse response,
HttpServlet servlet) throws ServletException, IOException
response.
The HttpServletResponse object.
servlet.
The HttpServlet object on which the actionHandler will be invoked.
Usage
Use this method to handle form actions. For example, if an application user presses a button in a web page form, the dispatchAction( ) method calls the button handler method that corresponds to the specific form and action.
The form, action, and corresponding handler are defined by the servlet developer in the servlet's NTV file.
Tip
It is useful to call formActionHandlerExists( ) before dispatchAction( ) to determine whether the servlet has form-actions defined on it.
Return Value
Returns NO_ERROR (a value of 0) if the method succeeds; otherwise, returns ERROR_NO_DISPATCH_HANDLER. (a value of 1), which means that dispatching cannot be done. If an event handler exists and is called, then dispatchAction( ) returns that handler's return value.
Related Topics
formActionHandlerExists( )
formActionHandlerExists( )
Determines whether the servlet has form-actions defined on it.
Syntax
public abstract boolean formActionHandlerExists()
Usage
This method accesses the NTV list and, by doing so, determines whether the servlet has form-actions defined on it. This information is useful to the dispatchAction( ) method, so you typically call formActionHandlerExists( ) before dispatchAction( ).
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Return Value
Returns true if form-actions are defined on the servlet.
Related Topics
dispatchAction( )
getAppLogic( )
Returns a handle to the AppLogic instance (ServletRunner) that served this request.
Syntax
public abstract AppLogic getAppLogic()
Usage
Use this method when you want to access the ServletRunner AppLogic. The getAppLogic( ) method lets developers call any AppLogic methods.
Tip
Deprecated AppLogic methods should not be called. For example, calling methods that stream data, such as streamResult( ), streamResultBinary( ), and streamResultHeader( ), may conflict with similar methods in HTTPResponse that also stream data.
Return Value
An AppLogic object.
Related Topics
AppLogic class
getDefaultTemplate( )
Retrieves the name of the file that handles output.
Syntax
public abstract String getDefaultTemplate()
Usage
In some cases, a servlet's NTV file indicates a default servlet or JSP file that handles output. If so, calling getDefaultTemplate( ) retrieves this NTV setting.
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Return Value
A String value representing the name of the default template.
Related Topics
setDefaultTemplate( )
getErrorCodes( )
Retrieves a vector of error codes.
Syntax
public abstract Vector getErrorCodes()
Return Value
A vector of error codes that correspond to the input variables that failed validation. A code is associated with each type of data validated, as summarized in the following table:
Related Topics
Chapter 13, "Taking Advantage of NAS Features," in the Programmer's Guide (Java).
getErrorMsgs( )
Retrieves a vector of error messages.
Syntax
public abstract Vector getErrorMsgs()
Return Value
A vector of error messages that correspond to the input variables that failed validation. A message is associated with each type of data validated, as summarized in the following table:
Related Topics
Chapter 13, "Taking Advantage of NAS Features," in the Programmer's Guide (Java).
getErrorVars( )
Retrieves a vector of input variables.
Syntax
public abstract Vector getErrorVars()
Return Value
A vector of the names of input variables that failed to validate.
Related Topics
Chapter 13, "Taking Advantage of NAS Features," in the Programmer's Guide (Java).
getHttpSessionBean( )
Retrieves an instance of a session object that is defined by the programmer.
Syntax 1
Use this syntax in most situations.
public abstract HttpSession getHttpSessionBean()
Syntax 2
Use this syntax to explicitly indicate whether to create the session or not.
public abstract HttpSession getHttpSessionBean(
boolean create)
create.
Supply a value of true if the session is to be created; otherwise, specify false.
Usage
The getHttpSessionBean( ) method retrieves the HttpSession or HttpSession2 object that is an instance of the class designated by the httpSessionBeanClass setting. This setting is defined in the SessionInfo section of an application's appInfo.ntv file. This setting allows application developers to provide bean-like HttpSession implementations.
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Return Value
An HttpSession or HttpSession2 object representing an instance of the class designated by httpSessionBeanClass.
Related Topics
getSession( ) in the javax.servlet.http.HttpServletRequest interface
getServletErrorHandler( )
Retrieves the object that handles validation errors.
Syntax
public abstract IServletErrorHandler getServletErrorHandler()
Usage
This method is used to retrieve the IServletErrorHandler object that handles errors that occur during validation. You can retrieve the object elsewhere if you need to call the included functionality.
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Return Value
The IServletErrorHandler object.
Related Topics
IServletErrorHandler interface
setDefaultTemplate( )
Sets the default template to another file.
Syntax
public abstract void setDefaultTemplate(
String template)
template.
The new name of the default template; the name applies only for this invocation of the servlet.
Usage
The default template is defined in a servlet's NTV file. However, in some cases it's useful to reset the default template to another file. To do so, call setDefaultTemplate( ). To retrieve the name of the current default template, call getDefaultTemplate( ).
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Related Topics
getDefaultTemplate( )
setServletErrorHandler( )
Sets the IServletErrorHandler that is used to process errors.
Syntax
public abstract void setServletErrorHandler(
IServletErrorHandler handler)
handler.
The error handler to be set.
Usage
A servlet error handler is always set on a request object by default. However, you may want to implement your own, so the setServletErrorHandler( ) method is provided to allow that.
This method sets the IServletErrorHandler that is used to process errors that happen during validation (and possibly elsewhere). To retrieve the IServletErrorHandler, call getServletErrorHandler( ).
Tip
This method appears in code generated by Netscape Application Builder. If you are not using NAB, you typically will not need to call this method.
Related Topics
getServletErrorHandler( )
validate( )
Validates input parameters and session variables.
Syntax 1
Use this version to validate all input parameters and session variables listed in the servlet's NTV file. This version also streams out an error on failure.
public abstract boolean validate(
HttpServletResponse response)
throws ServletException, IOException
Syntax 2
Use this version to validate specific input parameters and session variables (or those listed in the servlet's NTV file). This version also streams out an error on failure.
public abstract boolean validate(
String params[],
String sessionVars[],
HttpServletResponse response)
throws ServletException, IOException
Syntax 3
Use this version to validate specific input parameters and session variables (or those listed in the servlet's NTV file). No error streaming occurs.
public abstract boolean validate(
String params[],
String sessionVars[])
Syntax 4
Use this version to validate all input parameters and session variables listed in the servlet's NTV file. No error streaming occurs.
public abstract boolean validate()
response.
The HttpServletResponse object.
params.
The array of parameters to validate. Specify NULL to validate all input parameters listed in the NTV file.
sessionVars.
The array of session variables to validate. Specify NULL to validate all session variables listed in the NTV file.
Usage
Use this method whenever you want to validate parameters. There are four ways to invoke the validate( ) method. One version validates all input and session variables listed in a servlet's NTV file. Another version validates a specified array of input parameters or session variables. For each of these two versions, you can either ignore failure conditions or stream an error on failure.
When validate( ) is called and a validation error is detected, validate( ) then calls either of two IServletErrorHandler methods: handleInputValueError( ) or handleSessionVariableError( ). The previous two methods might return a positive number, meaning that a real error occurred and is queued into the error-specific vectors. If this happens, then streamError( ) is called once before validate( ) returns (assuming the validate( ) call is one of the two variants that streams errors).
The validate( ) method passes in one of the following error types as input to the two error handler methods, handleInputValueError( ) or handleSessionVariableError( ):
Return Value
Returns true if the validation was successful; otherwise, returns false.
Related Topics
IServletErrorHandler interface
|