Link to home
Start Free TrialLog in
Avatar of knaren_1975
knaren_1975

asked on

JSP Struts and JavaScript

Hi,
I am feeling it is very simple but I not able to do it.
My problem is I have to show one alert box once the data has successfully stored in to the database
I  am setting the saving status in the action class below like this.
try{
            relationship.save();/* relationship is hibernate object */
            statusOfEditContract="true";
            request.setAttribute("statusOfEditContract",statusOfEditContract);
        } catch(Exception e){
            statusOfEditContract="false";
              request.setAttribute("statusOfEditContract",statusOfEditContract);
        }
        return mapping.findForward("showPhases");
    }
The request object I am getting in JSP below like this
<html:form>
<!-- some code is there - ->
</html:form>
<body onLoad="saveContract()">
 <%
   if (request.getAttribute("statusOfEditContract").equals("true"))
   {
%>
<script language="javascript">
    function saveContract(){
    alert("Your Commitment Request has been Submitted");
    }
</script>
<%
   }
 %>
</body>
When I run this code I am able to see the alert box once data is successfully stored but I am seeing one small error at the status bar. Value is null or not object.
Please help me on this

Regards
Naren
ASKER CERTIFIED SOLUTION
Avatar of stanscott2
stanscott2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial