<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>R: [opencms-dev] Use of commons-fileupload with OpenCMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This works fine for me.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>// Create a JSP action
element<BR>CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext,
request, response);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>CmsObject cms =
cmsJsp.getCmsObject();<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Enumeration files =
cms.getRequestContext().getRequest().getFileNames();<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>in while loop try this:</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>filecontent = (byte[])
cmsJsp.getRequestContext().getRequest().getFile(fileName);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Works OK in OpenCMS 5.0.0 (RH 8, MySql 4.0.15, jdk
1.4)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Best regards,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Ivan Jelenic</DIV>
<DIV><BR></DIV></FONT>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=aldo.campione@siemens.com
href="mailto:aldo.campione@siemens.com">Campione Aldo</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=opencms-dev@opencms.org
href="mailto:opencms-dev@opencms.org">opencms-dev@opencms.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, March 18, 2004 9:55
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> R: [opencms-dev] Use of
commons-fileupload with OpenCMS</DIV>
<DIV><BR></DIV>
<P><FONT size=2>Hi Alexander,</FONT> </P>
<P><FONT size=2>I've tried your code but when I post a multipart-form data to
a JSP page I get anout of memory error.</FONT> <BR><FONT size=2>I've tried
this under tomact and it works.</FONT> </P>
<P><FONT size=2>Can you help me ?</FONT> </P><BR><BR>
<P><FONT size=2>-----Messaggio originale-----</FONT> <BR><FONT size=2>Da:
Alexander Kandzior [<A
href="mailto:alex@opencms.org">mailto:alex@opencms.org</A>] </FONT><BR><FONT
size=2>Inviato: venerd́ 6 febbraio 2004 12.11</FONT> <BR><FONT size=2>A: <A
href="mailto:opencms-dev@opencms.org">opencms-dev@opencms.org</A></FONT>
<BR><FONT size=2>Oggetto: RE: [opencms-dev] Use of commons-fileupload with
OpenCMS</FONT> </P><BR>
<P><FONT size=2>In fact OpenCms 5 automatically resolves the MIME Multipart
for you so you don't need to care about this in your OpenCms application.
</FONT></P>
<P><FONT size=2>You must use something like this to access the contents of
binary</FONT> <BR><FONT size=2>attachements:</FONT> </P>
<P><FONT size=2>CmsObject cms;</FONT> <BR><FONT size=2>...</FONT> <BR><FONT
size=2>Enumeration e =
cms.getRequestContext().getRequest().getFileNames();</FONT> <BR><FONT
size=2>while (e.hasMoreElements()) {</FONT> <BR><FONT size=2>
String name = (String)e.nextElement();</FONT> <BR><FONT size=2>
byte[] content = cms.getRequestContext().getRequest().getFile(name);</FONT>
<BR><FONT size=2> // do something with content</FONT> <BR><FONT
size=2>}</FONT> </P>
<P><FONT size=2>Best Regards,</FONT> <BR><FONT size=2>Alex.</FONT> </P>
<P><FONT size=2>Alexander Kandzior</FONT> <BR><FONT size=2>Alkacon Software -
The OpenCms Experts</FONT> <BR><FONT size=2><A href="http://www.alkacon.com"
target=_blank>http://www.alkacon.com</A></FONT> </P>
<P><FONT size=2>> -----Original Message-----</FONT> <BR><FONT size=2>>
From: opencms-dev-admin@opencms.org</FONT> <BR><FONT size=2>> [<A
href="mailto:opencms-dev-admin@opencms.org">mailto:opencms-dev-admin@opencms.org</A>]
On Behalf Of Ben Rometsch</FONT> <BR><FONT size=2>> Sent: Friday, February
06, 2004 10:34 AM</FONT> <BR><FONT size=2>> To:
opencms-dev@opencms.org</FONT> <BR><FONT size=2>> Subject: Re:
[opencms-dev] Use of commons-fileupload with OpenCMS</FONT> <BR><FONT
size=2>> </FONT><BR><FONT size=2>> </FONT><BR><FONT size=2>> Sorry to
bump a topic, but has anyone successfully used OpenCMS to</FONT> <BR><FONT
size=2>> upload files via a MIME Multipart http post? Not necessarily using
</FONT><BR><FONT size=2>> fileupload?</FONT> <BR><FONT size=2>>
</FONT><BR><FONT size=2>> Thanks,</FONT> <BR><FONT size=2>> Ben</FONT>
<BR><FONT size=2>> </FONT><BR><FONT size=2>> Ben Rometsch wrote:</FONT>
<BR><FONT size=2>> </FONT><BR><FONT size=2>> > Hi There,</FONT>
<BR><FONT size=2>> ></FONT> <BR><FONT size=2>> > I cannot get the
jakarta-commons file-upload API to work under</FONT> <BR><FONT size=2>>
> openCMS.</FONT> <BR><FONT size=2>> ></FONT> <BR><FONT size=2>>
> <A href="http://jakarta.apache.org/commons/fileupload/"
target=_blank>http://jakarta.apache.org/commons/fileupload/</A></FONT>
<BR><FONT size=2>> ></FONT> <BR><FONT size=2>> > According to
fileupload, the multi-part form request that</FONT> <BR><FONT size=2>> is
generated</FONT> <BR><FONT size=2>> > by the browser when trying to
upload a file contains NO name-value</FONT> <BR><FONT size=2>> > pairs.
I have run identical code in a pure tomcat/jsp </FONT><BR><FONT size=2>>
environment and</FONT> <BR><FONT size=2>> > it works fine.</FONT>
<BR><FONT size=2>> ></FONT> <BR><FONT size=2>> > Has anyone
successfully used file-upload with OpenCMS? Or is there </FONT><BR><FONT
size=2>> > another standard way of handling multipart forms?</FONT>
<BR><FONT size=2>> ></FONT> <BR><FONT size=2>> > Thanks,</FONT>
<BR><FONT size=2>> > Ben</FONT> <BR><FONT size=2>> ></FONT>
<BR><FONT size=2>> </FONT><BR><FONT size=2>> --</FONT> <BR><FONT
size=2>> ----== Solid State Group ==----</FONT> <BR><FONT size=2>>
Web www.solidstategroup.com</FONT> <BR><FONT
size=2>> Email ben@solidstategroup.com</FONT> <BR><FONT
size=2>> MSN benrometsch@hotmail.com</FONT>
<BR><FONT size=2>> </FONT><BR><FONT size=2>>
_______________________________________________</FONT> <BR><FONT size=2>>
This mail is send to you from the opencms-dev mailing list</FONT> <BR><FONT
size=2>> To change your list options, or to unsubscribe from the
list,</FONT> <BR><FONT size=2>> please visit <A
href="http://mail.opencms.org/mailman/listinfo/opencms-dev"
target=_blank>http://mail.opencms.org/mailman/listinfo/opencms-dev</A></FONT>
<BR><FONT size=2>> </FONT><BR><FONT size=2>> </FONT></P>
<P><FONT size=2>_______________________________________________</FONT>
<BR><FONT size=2>This mail is send to you from the opencms-dev mailing
list</FONT> <BR><FONT size=2>To change your list options, or to unsubscribe
from the list, please visit <A
href="http://mail.opencms.org/mailman/listinfo/opencms-dev"
target=_blank>http://mail.opencms.org/mailman/listinfo/opencms-dev</A></FONT></P></BLOCKQUOTE></BODY></HTML>