hi

As such you cannot control when system exception occur not in EJB also.

THough using follwoing code you can always transfer the user to the well
formed error page if in case it occurs.


public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){

if (this.isCancelled(request)){
System.out.println("*****The user pressed cancelled!!!");
return (mapping.findForward("poststory.success"));
}

PostStoryForm postStoryForm = (PostStoryForm) form;
//org.apache.struts.action.DynaActionForm postStoryForm =
(org.apache.struts.action.DynaActionForm) form;

HttpSession session = request.getSession();

MemberVO memberVO = (MemberVO) session.getAttribute("memberVO");

try{
System.out.println("****I am in post story******");
StoryVO storyVO = new StoryVO();

storyVO.setStoryIntro(postStoryForm.getStoryIntro());
storyVO.setStoryTitle(postStoryForm.getStoryTitle());
storyVO.setStoryBody(postStoryForm.getStoryBody());

/*storyVO.setStoryIntro((String)postStoryForm.get("storyIntro"));
storyVO.setStoryTitle((String)postStoryForm.get("storyTitle"));
storyVO.setStoryBody((String)postStoryForm.get("storyBody"));*/
storyVO.setStoryAuthor(memberVO);
storyVO.setSubmissionDate(new java.sql.Date(System.currentTimeMillis()));
storyVO.setComments(new Vector());

StoryManagerBD storyManager = new StoryManagerBD();
storyManager.addStory(storyVO);


System.out.println("****I am done with post story******");
}
catch(Exception e){
System.err.println("An application exception has been raised in
PostStory.perform(): " + e.toString());
return (mapping.findForward("system.failure"));
}

return (mapping.findForward("poststory.success"));
}

Hoope this will help

Cheers
Gary


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, November 24, 2003 3:12 PM
Subject: System Exception Handling in Struts


> Hello,
> How can I handle a system exception in Struts?
> Is Logging an internal part of Struts if yes how to configure it.
>
> Please help with an example if possible.
>
> Alok Garg
> Polaris Software Lab Ltd.
> ( + 91 - 022 - 28290019 Ext. # 1308 )
>
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to