Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

<html:errors> in JSP

843838Jul 19 2007 — edited Jul 20 2007
This is strange, I am working with the DAOS, business object, and struts.
The purpose of this is type a string and click submit, it should be adding a field in test table in mySQL.
The problem is when I click on it, and it'll forward to the success page. I checked the database, it didn't add. I am not getting any error messages in JSP. So, it's really hard for me to debug whatever it is. I made exceptions and properties. I placed the <html:errors/> in the submit page. It stills forward success page, and I didn't see any error messages in success page. I had a small example of getting SQL exceptions in JSP. It was really helpful for me to debug this. So I'm not sure how I can get exception messages from struts. Examples of those will be nice.

A big picture of this is fuzzy in my mind.
-I'm not sure how will the ActionError sends a message to the properties. Then the <html:errors> messages will show up. Here's the files that I'm working on.

AddAction - a struts Action
public class AddAction extends Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    protected static final String FAILURE = "failure";
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        ActionErrors errors = new ActionErrors();
        
        try {
        ClientBO clientBO = new ClientBO();
        clientBO.addSheet((SheetsForm)form);
        
        return mapping.findForward(SUCCESS);
        }
        catch (Throwable e) {
            e.printStackTrace();
            ActionMessage error = new ActionMessage(e.getMessage());
            errors.add(ActionErrors.GLOBAL_MESSAGE, error);
        }
    saveMessages(request,errors);
    return new ActionForward(mapping.getInput());
      
    }
}
This is a submit page.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html:errors/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <SCRIPT language="JavaScript" src="/js/ajax.js"></SCRIPT>
    <title></title>
</head>
<body onload="focusIn();">

<html:form action="addsheet" enctype="multipart/form-data" method="post">
<table border="1">
    
    <tr>
        <td>            Sheet:   </td>
        <td><html:text property="name" size="15"/></td>
    </tr>
    <tr>
        <td></td>
        <td><html:submit property="submit" value="Submit"/></td>
    </tr>
    </tbody>
</table>
</html:form>


</body>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 17 2007
Added on Jul 19 2007
7 comments
524 views