Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 5th, 2006, 06:30 PM
Registered User
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to display errors from Action class on the jsp


I have 2 jsps exceptionsList.jsp and feecompute.jsp

on clicking a button in exceptionsList.jsp i call

var ret = window.showModalDialog(appRoot + "/exceptionHandling.do?actionType=displayExcDet&flg= "+taskname, "AdHoc Portal", "dialogWidth:700px;dialogHeight:670px;help:no;scro ll:yes;status:yes;resizable:yes;");

 This opens up the feecompute.jsp.
 feecompute.jsp contains a struts form.
 On clicking the save button , I do

 var formToPost = "excHandlingActionForm";
               var str = formPOST(formToPost, url);

The Action class returns some errors, now i want to display these errors to the user on the same jsp or the a new jsp.
My problem is that when i do the alert(ret), i can see the expected result in it.
but a new jsp does not opens up neither the current jsp refreshes.

The code for formPost is

function formPOST(frm, url) {
    var str = buildPOST(frm);
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("POST", url, false);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    return xmlhttp.ResponseText;

function buildPOST(formName) {
    var frm = document.forms[formName];
    var POSTdata = "";
    var type = "";
    var on = false;
    var value = "";
    for (var i = 0; i < frm.elements.length; i++) {
        var name = frm.elements[i].name;
        if (frm.elements[i].type) {
            type = frm.elements[i].type;
            type = type.toLowerCase();
            if (type == "checkbox") {
                on = frm.elements[i].checked;
                if (on==true){
                    value = escape(frm.elements[i].value);
                else {
                    value = "";
            else {
                value = escape(frm.elements[i].value);
        else {
            value = escape(frm.elements[i].value);
        if (name != "") {

            if (POSTdata == "") {
                POSTdata = name + "=" + value;
            else {
                POSTdata += "&" + name + "=" + value;
    return POSTdata;

Now when i do something like below it works, but the window opened is not a modal one.

             //document.excHandlingActionForm.action = url;

can anyone help me in getting a modal window in which the errors are displayed.

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get linkname from jsp to struts action clas mona_1dec Struts 2 May 2nd, 2007 01:04 AM
how to display errors on jsp from action ntando Javascript How-To 0 December 5th, 2006 06:32 PM
I am not able to compile my Action class vivekkumar_23 Struts 2 May 4th, 2006 09:09 AM
Logger.getInstance in Action Class ramanadyv Struts 1 January 16th, 2006 05:44 AM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.