Exception handling in Jsp and Ejb's using WCS7.0 FrameWork

618 views Asked by At

I m doing work in WCS7.0 framework.I have to do exception handling of some EJB's code, eg if finder exception occurs i have to show a message on corresponding jsp "Data not Found".

below is EJB code

                  TypedProperty delParam = new TypedProperty();
        String shipid = rspProp.getString("shipid");
        String addrId=rspProp.getString("addrId");
        AddressAccessBean address = new AddressAccessBean();
        address.setInitKey_AddressId(addrId);
        try {
            if((address.getMemberId().equals(memberid)) &&          address.getAddressField3().equals(shipid)){
                address.getEJBRef().remove();

                }
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (CreateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FinderException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NamingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoveException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

what will i do to show message on jsp.

2

There are 2 answers

0
Lama On

I would recommend to read the first tutorial from IBM Websphere commerce 7 infocenter "Createing business logic" http://publib.boulder.ibm.com/infocenter/wchelp/v7r0m0/index.jsp

tutorials > programming model > Creating business logic

It explains how to bind actions and jsp pages using struts.

0
Daniel Persson On

You could either return it as a response property to show on your JSP view.

or

Throw an application exception to show the error on an generic error page.

throw new ECApplicationException(e);