File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Not able to see the errors on JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Not able to see the errors on JSP" Watch "Not able to see the errors on JSP" New topic
Author

Not able to see the errors on JSP

shiva
Greenhorn

Joined: Feb 03, 2004
Posts: 6
I am beginner. I have tried to create a two webpage struts app.

login.jsp ---->success----> main.jsp
----> failure---> login.jsp

Forcefully added some errors to simulate to display errors on login.jsp.

login.jsp is shown back without any errors...







Action Class's execute method:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("In execute() of LoginAction1");
ActionErrors errors = new ActionErrors();
System.out.println("In execute() of LoginAction2");
ActionForward forward = new ActionForward();
System.out.println(" In execute() of LoginAction3");
LoginForm loginForm = (LoginForm) form;

ActionMessages messages = new ActionMessages();
ActionMessage msg;
msg = new ActionMessage("error.userid.required");//, "Hellolll");
messages.add("msg1", msg);
saveMessages(request, messages);
//request.setAttribute("loginForm", loginForm);

try {

// do something here

} catch (Exception e) {

// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));

}

// Forcing it to have some errors....
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError(ActionErrors.GLOBAL_ERROR, "Helloooo" ));
errors.add("password", new ActionError("error.password.required"));
// errors.add("password", new ActionError("error.password.required"));
// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.

if (!errors.empty()) {
System.out.println("Errors exist. Forward to failure page.");
saveErrors(request, errors);
//request.g
forward = mapping.findForward("failure");
}
// Write logic determining how the user should be forwarded.
else forward = mapping.findForward("success");
//forward = mapping.findForward("failure");

// Finish with
return (forward);

}
---------------------------------------------------

ActionMapping:

<action-mappings>
<action name="loginForm" path="/login" scope="session" type="com.scoo.webstruts.actions.LoginAction" input="./Login.jsp" validate="true" >
<forward name="success" path="./Main.jsp">
</forward>
<forward name="failure" path="./Login.jsp">
</forward>
</action>
</action-mappings>
-------------------------------------------------------

<!-- Message Resources -->
<message-resources parameter="com.scoo.webstruts.resources.ApplicationResources"/>

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

Ho do I verify that app is able to take the strings from Resource files?

I am trying to test under WSAD Testing env and tried to do it on Tomcat too.

Thanks for any help.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Did you add a tag to your jsp for displaying the errors?


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to see the errors on JSP
 
Similar Threads
struts, error reporting
Struts DispatchAction "Wierd Parameter Error"
form bean doesn't come into picture
Struts DispatchAction "wierd parameter error"
Struts 1.1 upload multiple files with multiple input elements