Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 5th, 2006, 06:32 PM
Registered User
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to display errors on jsp from action


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.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 from Action class on the jsp ntando HTML Code Clinic 0 December 5th, 2006 06:30 PM
<jsp:useBean> action problem austinf JSP Basics 1 August 21st, 2006 04:23 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM
JSP Beans Errors harshadriswadkar JSP Basics 0 September 30th, 2003 06:22 AM

All times are GMT -4. The time now is 10:00 PM.

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