The multipart request is indeed a different request object. (It uses an org.apache.struts.upload.MultipartRequestWrapper) Why? Because getParameter() doesnt normally work on a multipart request! (Sun give some excuses about not parsing it for you cos multipart submissions arent a 'standard' or some such nonsense). Struts has to parse the multipart request (which is submitted to the server in quite a different format to a normal request) and it uses the class I mentioned above to store the parsed values. This is one of the many 'value added' features of struts that makes it cool - BUT the way it does it currently is ... how to say it ... "not how I wouldd have done it" (and before everyone asks me to write a patch - no I havent time right now. Maybe in January I will but doing the 100 hour a week "salt mines" work mode right now!) This parsing occurs in the static populate() method of the RequestUtils class - and it is called from the RequestProcessor.processPopulate() method. Guess what method of your ActionForm is called BEFORE populate()... Yep. The parameters for the multipart request are parsed AFTER reset() is called. No soup for you! :-( <btw> And if that action isnt using a form at all (rather rare) your request isnt populated at all! </btw>
Now there is one possible (quick) workaround - but you won't like it. You see while form fields that are submitted in the multipart request aren't available in the standard HttpServletRequest implementation, those that are appended as part of the url (ie /scooby.do?value1=bob&x=y etc...) are available. You could modify your script to append the userAction value to the forms action property. Heres an (edited) example from my own code where I append reset=true to the action url of entityForm if submit(true) is called. You can try modifying your code to do something similar and see if it helps. <snip> function submit(reset) { try { if(reset) { document.entityForm.action = appendParameter(document.entityForm.action,'reset','true'); } document.entityForm.submit(); } catch(error) { alert('Error caught by submit()\ntype=' + error.type + '\nname=' + error.name); throw error; } } function appendParameter(url, parameter, value) { var delimeter = url.indexOf('?') == -1 ? '?' : '&'; return url + delimeter + parameter + '=' + value; } </snip> -----Original Message----- From: Murray, Christopher [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 19, 2002 21:12 To: 'Struts Users Mailing List' Subject: Loosing my parameter in the multipart request Hey there guys n gals, I seem to be loosing a parameter of my request when I submit a multi-part form. In the page I have a, <input type="hidden" name="userAction"/> this is written to by a call to, <a href="javascript:submitFormDispatch('UploadForm','performUpload')">LINK</a> which calls, function submitFormDispatch( formname, value ) { var form = document.forms[ formname ]; var elements = form.elements; elements[ 'userAction' ].value = value; alert("userAction =" + value); form.submit(); } Now I know this is working because the alert pops up to tell me. When the reset method is called in the ActionForm I get a null pointer exception because no parameter is found for the action mapping set in the struts-config.xml, <action path="/.../upload" type="com...UploadAction" name="UploadForm" scope="session" validate="true" input="/.../upload.jsp" parameter="userAction"> <forward name="displayInputForm" path="/.../upload.jsp"></forward> <forward name="confirmUpload" path="/.../Upload_confirmed.jsp"></forward> <forward name="fail" path="/.../error"/> </action> And then in the form I've been using, public void reset(ActionMapping mapping, HttpServletRequest request){ FWLog log = FWLogManager.getLog("UploadActionForm"); log.debug("Entering UploadActionForm.reset"); System.out.println("mapping.getParameter() = " + mapping.getParameter()); System.out.println("request.getParameter(mapping.getParameter()) = "); System.out.println(request.getParameter(mapping.getParameter())); System.out.println("request = " + request.toString()); if (request.getParameter(mapping.getParameter()).equals(Constants.STAGE_ACTION_ METHOD)){ this.emailText = null; contactId = null; log.debug("email text has been reset."); } log.debug("Entering UploadActionForm.reset"); } When all this executes this outputs mapping.getParameter() = userAction request.getParameter(mapping.getParameter()) = null request = org.apache.struts.upload.MultipartRequestWrapper@799ca4 java.lang.NullPointerException at com...web.action.UploadActionForm.reset(Unknown Source) Guessing that a Multipart request is a different request object. Have you got any suggestions ? Is this possible ? -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>