Can I get some advice on this ?

Is it necessary to put a e.printStackTrace() if an error is caught at JSP
level ?

Hemika Kodikara
Software Engineer
WSO2 Inc.
lean . enterprise . middleware
http://wso2.com

Mobile : +94777688882

On Mon, Jan 26, 2015 at 11:38 AM, Hemika Kodikara <[email protected]> wrote:

> Hi All,
>
> What is the correct way to handle an exception when it comes to JSP pages ?
>
> Currently I have the following AJAX call on a JS file. This is called from
> another JSP file.
>
> function updatePermissions() {
>     var callback =
>     {
>         success:function(o) {
>             if (o.responseText !== undefined) {
>                 if (o.responseText.indexOf("Error") > -1) {
>                     CARBON.showErrorDialog("" + o.responseText, function()
> {
>                         location.href = "../queues/queue_details.jsp"
>                     });
>                 } else {
>                     CARBON.showInfoDialog("" + o.responseText, function() {
>                         location.href = "../queues/queue_details.jsp"
>                     });
>                 }
>
>             }
>         },
>         failure:function(o) {
>             if (o.responseText !== undefined) {
>                 alert("Error " + o.status + "\n Following is the message
> from the server.\n" + o.responseText);
>             }
>         }
>     };
>     var request = YAHOO.util.Connect.asyncRequest('POST',
> "update_queue_role_permissions_ajaxprocessor.jsp", callback);
> }
>
>
> The call is going to the the following file
> (update_queue_role_permissions_ajaxprocessor.jsp)
> update_queue_role_permissions_ajaxprocessor.jsp
> =======================================
> <%
>     // some code
>     QueueRolePermission[] queueRolePermissions = new
> QueueRolePermission[queueRolePermissionArrayList.size()];
>     try {
>         // some code
>         stub.updatePermission(queue,
> queueRolePermissionArrayList.toArray(queueRolePermissions));
>         message = "Queue added successfully";
>     } catch (AndesAdminServiceBrokerManagerAdminException e) {
>         // what to do here ?
>         message = "Error in adding/updating permissions : " +
> e.getMessage();
>     }
> %><%=message%>
>
>
> Concerns :
> 1. When an exception is caught, should the exception be logged at the JSP
> catch block or logged at where it is occurring at the higher level of code
> where the exception was thrown ?
>
> 2. If the exception is being logged at the JSP level, should it use log4j
> or an e.printStackTrace() ? e.printStackTrace usage at [1].
>
> [1] - https://docs.wso2.com/display/Governance460/Transition+UI+Sample
>
> Regards,
> Hemika
>
> Hemika Kodikara
> Software Engineer
> WSO2 Inc.
> lean . enterprise . middleware
> http://wso2.com
>
> Mobile : +94777688882
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to