Return-Path: Delivered-To: apmail-incubator-jspwiki-user-archive@locus.apache.org Received: (qmail 80115 invoked from network); 18 Oct 2008 16:26:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Oct 2008 16:26:04 -0000 Received: (qmail 86646 invoked by uid 500); 18 Oct 2008 16:26:05 -0000 Delivered-To: apmail-incubator-jspwiki-user-archive@incubator.apache.org Received: (qmail 86631 invoked by uid 500); 18 Oct 2008 16:26:05 -0000 Mailing-List: contact jspwiki-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-user@incubator.apache.org Delivered-To: mailing list jspwiki-user@incubator.apache.org Received: (qmail 86620 invoked by uid 99); 18 Oct 2008 16:26:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2008 09:26:05 -0700 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=MIME_QP_LONG_LINE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Janne.Jalkanen@ecyrd.com designates 193.64.5.122 as permitted sender) Received: from [193.64.5.122] (HELO mail.ecyrd.com) (193.64.5.122) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2008 16:24:57 +0000 Received: from [192.168.0.13] (cs181005170.pp.htv.fi [82.181.5.170]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.ecyrd.com (Postfix) with ESMTP id 78FF348288 for ; Sat, 18 Oct 2008 19:25:03 +0300 (EEST) Mime-Version: 1.0 (Apple Message framework v753.1) In-Reply-To: <48FA0C41.4000306@mail.upb.de> References: <36mkjz9PfJvx.jbKZHBdt@mail.ecyrd.com> <48F0937E.5050805@mail.upb.de> <35EC1CC5-1CF0-4910-A80F-DA1A0E0BEF7E@ecyrd.com> <48F0E442.5030303@mail.upb.de> <48F1AB05.6090900@mail.upb.de> <48F31F4C.3030804@mail.upb.de> <48F49EA6.1030202@mail.upb.de> <48F4A189.4030902@mail.upb.de> <4BF7FA48-EB05-42E3-9020-970EA14915EE@ecyrd.com> <48FA0852.3050903@mail.upb.de> <7BB438B5-C70A-4470-B974-B331A5CF29FB@ecyrd.com> <48FA0C41.4000306@mail.upb.de> Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: <82F3BF03-F434-4CF8-853D-9E83ADE26DA3@ecyrd.com> Content-Transfer-Encoding: quoted-printable From: Janne Jalkanen Subject: Re: VS: Re: Upload Question Date: Sat, 18 Oct 2008 19:24:35 +0300 To: jspwiki-user@incubator.apache.org X-Mailer: Apple Mail (2.753.1) X-Virus-Checked: Checked by ClamAV on apache.org Then I have no idea what is going on... /Janne On 18 Oct 2008, at 19:18, Benedikt Mohrmann wrote: > yes, I did so. > > > Janne Jalkanen schrieb: >> >> I think that URL is fine (otherwise you would get a 404 NOT =20 >> FOUND). Did you implement the doPost() method in your servlet? >> >> /Janne >> >> On 18 Oct 2008, at 19:01, Benedikt Mohrmann wrote: >> >>> Hi, >>> >>> thanks for the answer. >>> >>> Now I did the following: >>> First of all I modified my plugin, which creates me my uploadform: >>> returnStringBuffer.append("
"); >>> returnStringBuffer.append("
>> \"uploadForm\" accept-charset=3D\"UTF-8\" method=3D\"post\" enctype=3D= =20 >>> \"multipart/form-data\">"); >>> returnStringBuffer.append(">> \"formname\" value=3D\"uploadForm\"/>"); >>> returnStringBuffer.append(">> type=3D\"file\" value=3D\"\" />>> \"nbf_uploadFile\" id=3D\"upload\" value=3D\"Hochladen\" />"); >>> returnStringBuffer.append("
"); =20= >>> return returnStringBuffer.toString(); >>> >>> Then I wrote a servlet called MyServlet and created a .jar file =20 >>> of it. >>> I put this jar file in the "classes" directory of the JSPWiki and =20= >>> modiefied the web.xml the following way: >>> Added: >>> >>> MyServlet >>> MyServlet >>> >>> >>> MyServlet >>> /MyServlet >>> >>> >>> Now when I hit the submitbutton I get navigated to the page: >>> http://localhost:8080/JSPWiki/MyServlet >>> >>> which seems to be wrong. >>> >>> In addition I got the following error message on this page: >>> >>> >>> HTTP Status 405 - HTTP method POST is not supported by this URL >>> >>> --------------------------------------------------------------------=20= >>> ---- >>> >>> *type* Status report >>> >>> *message* _HTTP method POST is not supported by this URL_ >>> >>> *description* _The specified HTTP method is not allowed for the =20 >>> requested resource (HTTP method POST is not supported by this URL). >>> _ >>> >>> What am I doing wrong so far? >>> >>> Best regards >>> Benedikt >>> >>> >>> >>> >>> Janne Jalkanen schrieb: >>>> >>>> Ah yes, found the answer from the FAQ: >>>> >>>> "Why is parseRequest() returning no items? >>>> This most commonly happens when the request has already been =20= >>>> parsed, or processed in some other way. Since the input stream =20 >>>> has aleady been consumed by that earlier process, it is no =20 >>>> longer available for parsing by Commons FileUpload. " >>>> >>>> Therefore, since JSPWiki has already parsed the request (e.g. by =20= >>>> using request.getParameter()), FileUpload can no longer parse =20 >>>> the request and therefore fails. There is no way around this in =20= >>>> a Plugin, I'm afraid... >>>> >>>> The only option is probably to create your own Servlet and send =20 >>>> the request there. Look how AttachmentServlet handles things, =20 >>>> that should help you to construct your own Servlet to handle =20 >>>> your own upload. If you want to use WikiForms, you can use the =20 >>>> "submit" -parameter of FormOpen to point at your own servlet. >>>> >>>> /Janne >>>> >>>> On Oct 14, 2008, at 16:41 , Benedikt Mohrmann wrote: >>>> >>>>> Hi, >>>>> >>>>> I just tried another thing. >>>>> I wrote a second plugin which contains the following code: >>>>> StringBuffer returnStringBuffer =3D new StringBuffer(); >>>>> >>>>> @Override >>>>> public String execute(WikiContext context, Map params) =20 >>>>> throws PluginException { >>>>> returnStringBuffer.append("
>>>> \"wikiform\">"); >>>>> returnStringBuffer.append("
>>>> page=3DMyTest\" name=3D\"uploadForm\" accept-charset=3D\"UTF-8\" =20= >>>>> method=3D\"post\" enctype=3D\"multipart/form-data\">"); >>>>> returnStringBuffer.append(">>>> \"formname\" value=3D\"uploadForm\"/>"); >>>>> returnStringBuffer.append(">>>> \" type=3D\"file\" value=3D\"\" />>>>> \"nbf_uploadFile\" id=3D\"upload\" value=3D\"Hochladen\" />"); >>>>> returnStringBuffer.append("
>>>> div>"); return returnStringBuffer.toString(); >>>>> } >>>>> >>>>> } >>>>> >>>>> I integrated the plugin into a WikiPage and in addition the =20 >>>>> following: >>>>> [{FormOutput form=3D'uploadForm' handler=3D'MyPlugin'}] >>>>> >>>>> When I hit the button there happens nothing again. >>>>> >>>>> Now when I change the sourcecode an write >>>>> enctype=3D\"application/x-www-form-urlencoded\">" instead of =20 >>>>> enctype=3D\"multipart/form-data\">" >>>>> >>>>> everything works fine again. >>>>> >>>>> Something is definetely not able to handle the other format. >>>>> >>>>> Any ideas? >>>>> >>>>> Best regards >>>>> Benedikt >>>>> >>>>> >>>>> >>>>> >>>>> Benedikt Mohrmann schrieb: >>>>>> Hi, >>>>>> >>>>>> I definetely know that it is a problem with the =20 >>>>>> MyFormOpenPlugin!!! >>>>>> >>>>>> No plugin gets activated, when I use the MyFormOpenPlugin. >>>>>> >>>>>> I just copied the FormOpen Plugin and changed the one line to =20 >>>>>> get a "multipart/form-data". >>>>>> In addition I deleted the following: >>>>>> private static org.apache.log4j.Logger log =3D >>>>>> org.apache.log4j.Logger.getLogger( MyFormOpen.class ); >>>>>> >>>>>> log.debug( "Previous FormInfo for this form was found in =20 >>>>>> context." ); >>>>>> >>>>>> >>>>>> But I don`t think that this can be the problem. >>>>>> >>>>>> Is there any other way to get out of this mysery? >>>>>> >>>>>> Best regards >>>>>> Benedikt >>>>>> >>>>>> >>>>>> Benedikt Mohrmann schrieb: >>>>>>> Hi, >>>>>>> >>>>>>> does anyone have a clue, how to solve this problem? >>>>>>> >>>>>>> Best regards >>>>>>> Benedikt >>>>>>> >>>>>>> >>>>>>> Benedikt Mohrmann schrieb: >>>>>>>> Hi, >>>>>>>> >>>>>>>> here is the resulting HTML code: >>>>>>>> >>>>>>>>
>>>>>>>>
>>>>>>> charset=3D"UTF-8" method=3D"post" = enctype=3D"multipart/form-data"> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>

>>>>>>>>

>>>>>>>>

>>>>>>>> >>>>>>>>

>>>>>>>>
>>>>>>>> >>>>>>>> Regards >>>>>>>> Benedikt >>>>>>>> >>>>>>>> >>>>>>>> Janne Jalkanen schrieb: >>>>>>>>> And could you also provide the HTML code resulting from =20 >>>>>>>>> this invocation? >>>>>>>>> >>>>>>>>> /Janne >>>>>>>>> >>>>>>>>> On 11 Oct 2008, at 20:37, Benedikt Mohrmann wrote: >>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> the plugin should be activated by a click on the button. >>>>>>>>>> >>>>>>>>>> Here is the WikiPage >>>>>>>>>> >>>>>>>>>> [{FormSet form=3D'uploadForm'}] >>>>>>>>>> [{MyFormOpen form=3D'uploadForm'}] >>>>>>>>>> [{FormInput type=3D'file' name=3D'uploadInput'}] >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> [{FormInput type=3D'submit' name=3D'uploadFile' = value=3D'Upload'}] >>>>>>>>>> [{FormOutput form=3D'uploadForm' handler=3D'MyPlugin'}] >>>>>>>>>> [{FormClose}] >>>>>>>>>> >>>>>>>>>> Best regards >>>>>>>>>> Benedikt >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Janne Jalkanen schrieb: >>>>>>>>>>> >>>>>>>>>>> And how do you use this on a page? >>>>>>>>>>> >>>>>>>>>>> /Janne >>>>>>>>>>> >>>>>>>>>>> On 11 Oct 2008, at 14:52, Benedikt Mohrmann wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi, >>>>>>>>>>>> >>>>>>>>>>>> the plugin is quite easy: >>>>>>>>>>>> public class MyPlugin implements WikiPlugin { >>>>>>>>>>>> >>>>>>>>>>>> @Override >>>>>>>>>>>> public String execute(WikiContext context, Map =20 >>>>>>>>>>>> params) throws PluginException { >>>>>>>>>>>> HttpServletRequest request =3D =20 >>>>>>>>>>>> context.getHttpRequest(); >>>>>>>>>>>> boolean isMultipart =3D =20 >>>>>>>>>>>> ServletFileUpload.isMultipartContent(request); >>>>>>>>>>>> // Create a factory for disk-based file items >>>>>>>>>>>> FileItemFactory factory =3D new = DiskFileItemFactory(); >>>>>>>>>>>> >>>>>>>>>>>> // Create a new file upload handler >>>>>>>>>>>> ServletFileUpload upload =3D new ServletFileUpload=20= >>>>>>>>>>>> (factory); >>>>>>>>>>>> >>>>>>>>>>>> // Parse the request >>>>>>>>>>>> List items =3D null; >>>>>>>>>>>> try { >>>>>>>>>>>> items =3D upload.parseRequest(request); >>>>>>>>>>>> } catch (Exception e) { >>>>>>>>>>>> // TODO Auto-generated catch block >>>>>>>>>>>> return "BUG"; >>>>>>>>>>>> } >>>>>>>>>>>> boolean empty =3D items.isEmpty(); >>>>>>>>>>>> String valueOf =3D String.valueOf(empty); >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> return valueOf + "Works"; >>>>>>>>>>>> } >>>>>>>>>>>> } >>>>>>>>>>>> >>>>>>>>>>>> As I said, when I hit the submitButton nothing happens. >>>>>>>>>>>> >>>>>>>>>>>> Best regards >>>>>>>>>>>> Benedikt >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> jalkanen@ecyrd.com schrieb: >>>>>>>>>>>>> Hi! >>>>>>>>>>>>> >>>>>>>>>>>>> I think we might need to see the code. Can you post it =20 >>>>>>>>>>>>> to the list, please? >>>>>>>>>>>>> >>>>>>>>>>>>> /janne >>>>>>>>>>>>> >>>>>>>>>>>>> -- alkuper. viesti -- >>>>>>>>>>>>> Aihe: Re: Upload Question >>>>>>>>>>>>> L=E4hett=E4j=E4: Benedikt Mohrmann >>>>>>>>>>>>> P=E4iv=E4m=E4=E4r=E4: 11.10.2008 12:42 >>>>>>>>>>>>> >>>>>>>>>>>>> Hi, >>>>>>>>>>>>> >>>>>>>>>>>>> I did all this. >>>>>>>>>>>>> The HTML output is how it should be, but the request is =20= >>>>>>>>>>>>> not handled when I hit the button. >>>>>>>>>>>>> >>>>>>>>>>>>> The WikiSite: >>>>>>>>>>>>> [{FormSet form=3D'uploadForm'}] >>>>>>>>>>>>> [{MyFormOpen form=3D'uploadForm'}] >>>>>>>>>>>>> [{FormInput type=3D'file' name=3D'uploadInput'}] >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> [{FormInput type=3D'submit' name=3D'uploadFile' =20 >>>>>>>>>>>>> value=3D'Upload'}] >>>>>>>>>>>>> [{FormOutput form=3D'uploadForm' handler=3D'MyPlugin'}] >>>>>>>>>>>>> [{FormClose}] >>>>>>>>>>>>> >>>>>>>>>>>>> To test it I wrote a plugin which justs returns "Works". >>>>>>>>>>>>> Now when I switch to the normal FormOpen tag =20 >>>>>>>>>>>>> ([{FormOpen form=3D'uploadForm'}]) the output is "Works". >>>>>>>>>>>>> When I use my own one, there is no output. >>>>>>>>>>>>> >>>>>>>>>>>>> Any ideas, why this is not handled? >>>>>>>>>>>>> >>>>>>>>>>>>> Best regards >>>>>>>>>>>>> Benedikt >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Janne Jalkanen schrieb: >>>>>>>>>>>>> >>>>>>>>>>>>>> They are real plugins. >>>>>>>>>>>>>> >>>>>>>>>>>>>> I recommend that you copy FormOpen.java to =20 >>>>>>>>>>>>>> MyFormOpen.java, rename the class, change the code, =20 >>>>>>>>>>>>>> and then use [{MyFormOpen}] instead of [{FormOpen}] in =20= >>>>>>>>>>>>>> the plugins that you need. >>>>>>>>>>>>>> >>>>>>>>>>>>>> You can easily write your own plugin which does what =20 >>>>>>>>>>>>>> you said: >>>>>>>>>>>>>> >>>>>>>>>>>>>> package whatever.package.you.use; >>>>>>>>>>>>>> >>>>>>>>>>>>>> public class MyPlugin implements WikiPlugin >>>>>>>>>>>>>> { >>>>>>>>>>>>>> public String execute(WikiContext ctx, Map params) >>>>>>>>>>>>>> { >>>>>>>>>>>>>> returnStringBuffer.append("
>>>>>>>>>>>>> \"wikiform\">"); >>>>>>>>>>>>>> returnStringBuffer.append("
>>>>>>>>>>>>> \"Wiki.jsp?page=3DMyTest\" name=3D\"uploadForm\" accept-=20= >>>>>>>>>>>>>> charset=3D\"UTF-8\" method=3D\"post\" =20= >>>>>>>>>>>>>> enctype=3D\"multipart/form-data\">"); >>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>> \" name=3D\"formname\" value=3D\"uploadForm\"/>"); >>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>> \"nbf_Datei\" type=3D\"file\">>>>>>>>>>>>>> name=3D\"nbf_upload\" id=3D\"upload\" value=3D\"Hochladen\"= /=20 >>>>>>>>>>>>>> >"); >>>>>>>>>>>>>> >>>>>>>>>>>>>> return returnStringBuffer.toString(); >>>>>>>>>>>>>> } >>>>>>>>>>>>>> } >>>>>>>>>>>>>> >>>>>>>>>>>>>> then use [{whatever.package.you.use.MyPlugin}] on a =20 >>>>>>>>>>>>>> wikipage. I don't know what it does, but it is easy :-) >>>>>>>>>>>>>> >>>>>>>>>>>>>> /Janne >>>>>>>>>>>>>> >>>>>>>>>>>>>> On Oct 10, 2008, at 16:16 , Benedikt Mohrmann wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> the problem is that the Forms are directly in the =20 >>>>>>>>>>>>>>> JSPWiki.jar file. >>>>>>>>>>>>>>> Thus they are no real plugins I guess. >>>>>>>>>>>>>>> I tried to change the FormOpen.java and inserted >>>>>>>>>>>>>>> tag.append( "\" method=3D\""+method+"\" enctype=3D=20= >>>>>>>>>>>>>>> \"multipart/form-data\">\n" ); >>>>>>>>>>>>>>> then build the class file and just put it into the =20 >>>>>>>>>>>>>>> JSPWiki.jar. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> As a result all the other plugins which use forms =20 >>>>>>>>>>>>>>> were not working correctly (that was of course clear). >>>>>>>>>>>>>>> But my Upload Plugin did not work, too. >>>>>>>>>>>>>>> When I hit the submit button nothing happened. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Is there no possibility to insert a plugin which =20 >>>>>>>>>>>>>>> creates HTML code the following way: >>>>>>>>>>>>>>> returnStringBuffer.append("
>>>>>>>>>>>>>> \"wikiform\">"); >>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>> \"Wiki.jsp?page=3DMyTest\" name=3D\"uploadForm\" accept-=20= >>>>>>>>>>>>>>> charset=3D\"UTF-8\" method=3D\"post\" = enctype=3D\"multipart/=20 >>>>>>>>>>>>>>> form-data\">"); >>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>> \" name=3D\"formname\" value=3D\"uploadForm\"/>"); >>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>> \"nbf_Datei\" type=3D\"file\">>>>>>>>>>>>>>> name=3D\"nbf_upload\" id=3D\"upload\" value=3D\"Hochladen=20= >>>>>>>>>>>>>>> \" />"); >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Then just integrate the plugin into the WikiPage. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> And then put a second plugin via [{FormOutput =20 >>>>>>>>>>>>>>> form=3D'uploadForm' handler=3D'MyPlugin'}] into the =20 >>>>>>>>>>>>>>> WikiPage? >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> At the moment this seems not to work, as nothing =20 >>>>>>>>>>>>>>> happens when I click on the submit button. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Best regards >>>>>>>>>>>>>>> Benedikt >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Janne Jalkanen schrieb: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Probably the quickest way for you now is to simply =20 >>>>>>>>>>>>>>>> make a copy of the >>>>>>>>>>>>>>>> relevant Form plugin, name it something else, and =20 >>>>>>>>>>>>>>>> just change the >>>>>>>>>>>>>>>> enctype. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Also please put in a JIRA request for the enctype to =20= >>>>>>>>>>>>>>>> be changeable, >>>>>>>>>>>>>>>> and we'll snatch it in either 2.8.1 or 3.0. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> /Janne >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On Fri, Oct 10, 2008 at 10:50:32AM +0200, Benedikt =20 >>>>>>>>>>>>>>>> Mohrmann wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> just checked it again. >>>>>>>>>>>>>>>>> The problem is definetely the form: >>>>>>>>>>>>>>>>> org.apache.commons.fileupload.FileUploadBase=20 >>>>>>>>>>>>>>>>> $InvalidContentTypeException: the request doesn't =20 >>>>>>>>>>>>>>>>> contain a multipart/form-data or multipart/mixed =20 >>>>>>>>>>>>>>>>> stream, content type header is application/x-www-=20 >>>>>>>>>>>>>>>>> form-urlencoded >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Pretty bad that you can not change the enctype. >>>>>>>>>>>>>>>>> In the Wiki Src it is: >>>>>>>>>>>>>>>>> tag.append( "\" method=3D\""+method+"\" enctype=3D=20 >>>>>>>>>>>>>>>>> \"application/x-www-form-urlencoded\">\n" ); >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Can't I just change this? >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Another way could be to write a plugin with the =20 >>>>>>>>>>>>>>>>> following code (snippet): >>>>>>>>>>>>>>>>> returnStringBuffer.append("
>>>>>>>>>>>>>>>> \"wikiform\">"); >>>>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>>>> \"Wiki.jsp?page=3DMyTest\" name=3D\"uploadForm\" = accept-=20 >>>>>>>>>>>>>>>>> charset=3D\"UTF-8\" method=3D\"post\" enctype=3D=20 >>>>>>>>>>>>>>>>> \"multipart/form-data\">"); >>>>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>>>> \"hidden\" name=3D\"formname\" = value=3D\"uploadForm\"/>"); >>>>>>>>>>>>>>>>> returnStringBuffer.append(">>>>>>>>>>>>>>>> \"nbz_Datei\" type=3D\"file\">>>>>>>>>>>>>>>>> name=3D\"nbz_upload\" id=3D\"upload\" = value=3D\"Hochladen=20 >>>>>>>>>>>>>>>>> \" />"); >>>>>>>>>>>>>>>>> returnStringBuffer.append("
"); >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> This would create a form, but how can I tell the =20 >>>>>>>>>>>>>>>>> Wiki which plugin to use, when the button is hit? >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Regards >>>>>>>>>>>>>>>>> Benedikt >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Janne Jalkanen schrieb: >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> I think it is important to look into the cause... =20 >>>>>>>>>>>>>>>>>> The stack trace would be important, yes. There =20 >>>>>>>>>>>>>>>>>> could be many things failing. >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> /Janne >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> On Oct 9, 2008, at 19:15 , Harry Metske wrote: >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> I think so too (multipart/form-data), but can you =20= >>>>>>>>>>>>>>>>>>> print the stacktrace just >>>>>>>>>>>>>>>>>>> before returning " BUG" , maybe you'll get a clue =20= >>>>>>>>>>>>>>>>>>> then ? >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> The FormOpen class currently has a hardcoded >>>>>>>>>>>>>>>>>>> "application/x-www-form-urlencoded", I think this =20= >>>>>>>>>>>>>>>>>>> should be parameterizable >>>>>>>>>>>>>>>>>>> with the current value as the default. >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> regards, >>>>>>>>>>>>>>>>>>> Harry >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> 2008/10/9 Benedikt Mohrmann >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I tried a few things already, but did not get it =20= >>>>>>>>>>>>>>>>>>>> to work so far. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> At first I created a new site, which contains: >>>>>>>>>>>>>>>>>>>> [{FormSet form=3D'searchForm'}] >>>>>>>>>>>>>>>>>>>> [{FormOpen form=3D'searchForm'}] >>>>>>>>>>>>>>>>>>>> [{FormInput type=3D'file' name=3D'searchInput'}] >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> [{FormInput type=3D'submit' name=3D'submit' =20 >>>>>>>>>>>>>>>>>>>> value=3D'Submit'}] >>>>>>>>>>>>>>>>>>>> [{FormClose}] >>>>>>>>>>>>>>>>>>>> [{FormOutput form=3D'searchForm' = handler=3D'MyTest2'}] >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Thus there is only a form where you can upload =20 >>>>>>>>>>>>>>>>>>>> your data. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> The Plugin contains the following code (at this =20 >>>>>>>>>>>>>>>>>>>> time really simple, just to >>>>>>>>>>>>>>>>>>>> check if it works): >>>>>>>>>>>>>>>>>>>> public class MyTest2 implements WikiPlugin { >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> @Override >>>>>>>>>>>>>>>>>>>> public String execute(WikiContext context, Map =20 >>>>>>>>>>>>>>>>>>>> params) throws >>>>>>>>>>>>>>>>>>>> PluginException { >>>>>>>>>>>>>>>>>>>> HttpServletRequest request =3D =20 >>>>>>>>>>>>>>>>>>>> context.getHttpRequest(); >>>>>>>>>>>>>>>>>>>> boolean isMultipart =3D =20 >>>>>>>>>>>>>>>>>>>> ServletFileUpload.isMultipartContent(request); >>>>>>>>>>>>>>>>>>>> // Create a factory for disk-based =20 >>>>>>>>>>>>>>>>>>>> file items >>>>>>>>>>>>>>>>>>>> FileItemFactory factory =3D new =20 >>>>>>>>>>>>>>>>>>>> DiskFileItemFactory(); >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> // Create a new file upload handler >>>>>>>>>>>>>>>>>>>> ServletFileUpload upload =3D new =20 >>>>>>>>>>>>>>>>>>>> ServletFileUpload(factory); >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> // Parse the request >>>>>>>>>>>>>>>>>>>> List items =3D null; >>>>>>>>>>>>>>>>>>>> try { >>>>>>>>>>>>>>>>>>>> items =3D upload.parseRequest(request); >>>>>>>>>>>>>>>>>>>> } catch (Exception e) { >>>>>>>>>>>>>>>>>>>> // TODO Auto-generated catch block >>>>>>>>>>>>>>>>>>>> return "BUG"; >>>>>>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>>>>>> return "Works"; >>>>>>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> So far I always get the "BUG" output when I =20 >>>>>>>>>>>>>>>>>>>> choose a file and hit the >>>>>>>>>>>>>>>>>>>> submitbutton. >>>>>>>>>>>>>>>>>>>> One problem could be that when I take a look at =20 >>>>>>>>>>>>>>>>>>>> the produced HTML code, the >>>>>>>>>>>>>>>>>>>> form is introduced with: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> name=3D"searchForm" >>>>>>>>>>>>>>>>>>>> accept-charset=3D"UTF-8" method=3D"post" >>>>>>>>>>>>>>>>>>>> enctype=3D"application/x-www-form-urlencoded"> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> I think it should be the enctype: multipart/form-=20= >>>>>>>>>>>>>>>>>>>> data >>>>>>>>>>>>>>>>>>>> But I don't know if that is the point. >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Any other ideas? >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Best regards >>>>>>>>>>>>>>>>>>>> Benedikt >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> Harry Metske schrieb: >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> my previous answer was a bit too much in a =20 >>>>>>>>>>>>>>>>>>>>> hurry.... >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> first your compile, Eclipse tells you there is =20 >>>>>>>>>>>>>>>>>>>>> no method getHttpRequest >>>>>>>>>>>>>>>>>>>>> for >>>>>>>>>>>>>>>>>>>>> a wiki context, that is strange, looking at the =20= >>>>>>>>>>>>>>>>>>>>> source it does have it : >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> ........ >>>>>>>>>>>>>>>>>>>>> /** >>>>>>>>>>>>>>>>>>>>> * If the request did originate from a HTTP =20 >>>>>>>>>>>>>>>>>>>>> request, >>>>>>>>>>>>>>>>>>>>> * then the HTTP request can be fetched =20 >>>>>>>>>>>>>>>>>>>>> here. However, it the request >>>>>>>>>>>>>>>>>>>>> * did NOT originate from a HTTP request, =20 >>>>>>>>>>>>>>>>>>>>> then this method will >>>>>>>>>>>>>>>>>>>>> * return null, and YOU SHOULD CHECK FOR IT! >>>>>>>>>>>>>>>>>>>>> * >>>>>>>>>>>>>>>>>>>>> * @return Null, if no HTTP request was done. >>>>>>>>>>>>>>>>>>>>> * @since 2.0.13. >>>>>>>>>>>>>>>>>>>>> */ >>>>>>>>>>>>>>>>>>>>> public HttpServletRequest getHttpRequest() >>>>>>>>>>>>>>>>>>>>> { >>>>>>>>>>>>>>>>>>>>> return m_request; >>>>>>>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>>>>>>> ....... >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> and if you can't compile it, I shouldn't even =20 >>>>>>>>>>>>>>>>>>>>> try to run it. >>>>>>>>>>>>>>>>>>>>> Maybe you can reply the complete source of your =20= >>>>>>>>>>>>>>>>>>>>> plugin ? >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> regards, >>>>>>>>>>>>>>>>>>>>> Harry >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> 2008/10/8 Benedikt Mohrmann >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> thanks for your answer- I already had a look =20 >>>>>>>>>>>>>>>>>>>>>> at commons fileupload. >>>>>>>>>>>>>>>>>>>>>> But the problem is, when I use: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> HttpServletRequest request =3D =20 >>>>>>>>>>>>>>>>>>>>>> context.getHttpRequest(); >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> JSPWiki tells me >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> HttpServletRequest cannot be resolved to a type >>>>>>>>>>>>>>>>>>>>>> The type javax.servlet.http.HttpServletRequest =20= >>>>>>>>>>>>>>>>>>>>>> cannot be resolved. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> In addition I am implementing my plugin in =20 >>>>>>>>>>>>>>>>>>>>>> Eclipse and it tells me that >>>>>>>>>>>>>>>>>>>>>> there is no method getHttpRequest for a wiki =20 >>>>>>>>>>>>>>>>>>>>>> context. >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Best regards >>>>>>>>>>>>>>>>>>>>>> Benedikt >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Harry Metske schrieb: >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> Benedikt, >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> in your plugin you have access to the =20 >>>>>>>>>>>>>>>>>>>>>>> HttpServletRequest ( >>>>>>>>>>>>>>>>>>>>>>> HttpServletRequest request =3D =20 >>>>>>>>>>>>>>>>>>>>>>> context.getHttpRequest(); ) . >>>>>>>>>>>>>>>>>>>>>>> Once you have this, I think you can use many =20 >>>>>>>>>>>>>>>>>>>>>>> samples/tools to handle the >>>>>>>>>>>>>>>>>>>>>>> uploaded file, but maybe the best one is =20 >>>>>>>>>>>>>>>>>>>>>>> commons fileupload ( >>>>>>>>>>>>>>>>>>>>>>> http://commons.apache.org/fileupload/=20 >>>>>>>>>>>>>>>>>>>>>>> using.html), this binary jar is >>>>>>>>>>>>>>>>>>>>>>> already >>>>>>>>>>>>>>>>>>>>>>> in the JSPWiki distribution. >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> regards, >>>>>>>>>>>>>>>>>>>>>>> Harry >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> 2008/10/7 Benedikt Mohrmann =20 >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> my intention is to upload a file via =20 >>>>>>>>>>>>>>>>>>>>>>>> JSPWiki, but not as an attachment. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> I am trying to upload a file, thus I created =20= >>>>>>>>>>>>>>>>>>>>>>>> a form containing a file >>>>>>>>>>>>>>>>>>>>>>>> chooser and a submitbutton. >>>>>>>>>>>>>>>>>>>>>>>> The goal is, that the input file is =20 >>>>>>>>>>>>>>>>>>>>>>>> transferred to the server and then >>>>>>>>>>>>>>>>>>>>>>>> handled by a plugin I wrote. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> The plugin just puts the file as a =20 >>>>>>>>>>>>>>>>>>>>>>>> Serializable into a database (which >>>>>>>>>>>>>>>>>>>>>>>> already works, when I read a file from my =20 >>>>>>>>>>>>>>>>>>>>>>>> harddisk). >>>>>>>>>>>>>>>>>>>>>>>> But I am not yet not able to transfer the =20 >>>>>>>>>>>>>>>>>>>>>>>> content of the file as a >>>>>>>>>>>>>>>>>>>>>>>> stream >>>>>>>>>>>>>>>>>>>>>>>> or something like that. >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Any experiences how this could work? >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> Best regards >>>>>>>>>>>>>>>>>>>>>>>> Benedikt >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>> >>