Navigation Menu

ATG Form Handler

Difference between sendLocalRedirect() and SendRedirect()


Sites developed on ATG Framework, sometimes send url appended with ?_requestid. This is happening only when we are using sendLocalRedirect() instead of sendRedirect().If a request results in a redirect to a local page through the method HttpServletResponse.sendLocalRedirect(), the ATG platform treats the redirect request as part of the original request, and maintains any request-scoped objects associated with that request. To implement this, the ATG platform adds an additional query parameter named _requestid to the redirected URL.

Differences -
sendLocalRedirect() - using when user need to redirect on the same site with relative or full path. Also when we need to pass session id with the response.
HttpServletResponse.sendLocalRedirect("./sample/test.jsp",HttpServletResquest)
sendRedirect() - using when user need to redirect to different site with full path.
HttpServletResponse.sendRedirect("www.test.com/sample/test.jsp",HttpServletResquest)


Difference between DynamoHttpServletRequst/Response and HttpServletRequest/Response


HttpServletRequest/Response interface is immutable. It only provides method for reading. DynamoHttpServletRequest implement HttpServletRequest and provides methods to change request.Similarly, DynamoHttpServletResponse implement HttpServletResponse and provides methods to change response such as output stream.

Servlet pipeline converts Http request/ response to DymanoHttp request/response


Example to create FormHandler and call from dsp page : 

       For creating a Form Handler, Component should extends one-


  • EmptyFormHandler : will provide the basic map data stracture(after/before Set/Get) and holds the form data.
  • GenericFormHandler : will provide the basic error checking operations. (commonly used to create FormHandlers)
  • TransactionFromHandler : will provide the transaction management capabilities while processing form inputs.
  • All of the above FormHandlers implements DropletFromHandlers.

Creating UserInfoFormHandler component :

  • UserInfoFromHandler.properties :
           $class=com.profile.UserInfoFromHandler           
           $scope=request
  • UserInfoFromHandler.java :
package com.profile
public class UserInfoFromHandler extends atg.droplet.GenericFormHandler {
           public boolean handleTestProfile(DynamoHttpRequest request, DynamoHttpResponse response) throws ServletException, IOException{
           logDebug(getUserId());
           return checkFormRedirect(getSendSuccessURL(), getSendErrorURL(), request, response); 
           }
    
           private String userId; 
           public String getUserId(){return userId;}
           public void setUserId(String userId) {this.userId = userId;}

           private String sendSuccessURL;  
           public String getSendSuccessURL() {return sendSuccessURL; }
           public void setSendSuccessURL(String sendSuccessURL) {this.sendSuccessURL = sendSuccessURL;}

           private String sendErrorURL;
           public String getSendErrorURL() {return sendErrorURL; }
           public void setSendErrorURL(String sendErrorURL) {this.sendErrorURL = sendErrorURL;}
    }
  • DSP Page :
<dsp:page>
<dsp:import bean="/com/profile/UserInfoFromHandler"/>
<dsp:form name="subscriptionForm" action="Success.jsp">
Email ID: <dsp:input  type="text" id="userId" bean="UserInfoFromHandler.userId"  />
<dsp:input type="submit" bean="UserInfoFromHandler.TestProfile" id="submitForm" value=""/>
<dsp:input type="hidden" bean="UserInfoFromHandler.sendSuccessURL"  value="success.jsp" />
<dsp:input type="hidden" bean="UserInfoFromHandler.sendErrorURL" value= "${url}" />
</dsp:form>
</dsp:page>