You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pete Raleigh <pe...@lwwcm.com> on 2005/04/01 15:13:00 UTC

RE: [PortletFileUpload] class compiling error

Alfredo,

After downloading all of the dependencies, I have managed to get the Portlet
to compile. A big "thank you" for your assistance. In WPS 5.1 there isn't a
servlet-api.jar as such, it is located in the AppServer/lib/j2ee.jar (for
any users who can't seem to find it).

After running a simple test, it also appears to be doing what it is supposed
to do. Do you know why there are so many dependencies as it is a shame to
have to package all of these JAR files within a WAR / EAR for such a small
piece of code?

Cheers, Pete.


-----Original Message-----
From: Alfredo Ledezma Melendez [mailto:alfredo.ledezma@mail.telcel.com] 
Sent: 31 March 2005 22:51
To: Jakarta Commons Users List
Subject: RE: [PortletFileUpload] class compiling error

Please check http://jakarta.apache.org/commons/fileupload/dependencies.html

Regards,
____________________________________________
Alfredo Ledezma Melendez.
Costumer Record Management
Consultor Externo de Sistemas de Atencion a Clientes RadioMovil DIPSA, S. A.
de C. V.
Ejercito Nacional No. 488, Col. Anahuac, C.P. 11570 Mexico D.F. 

-----Original Message-----
From: Pete Raleigh [mailto:pete.raleigh@lwwcm.com]
Sent: Thursday, March 31, 2005 3:36 PM
To: commons-user@jakarta.apache.org
Subject: RE: [PortletFileUpload] class compiling error

That's because it isn't a "servlet" - it's a portlet. Are these files really
necessary? It uses the ActionRequest object, rather than an
HttpServletRequest object - which are very different in a Portal Server. I
have been struggling with this all day and have still not progressed very
far. Has anyone managed to upload a file through a Portlet (JSR 168) or is
this not possible?

Cheers, Pete.

-----Original Message-----
From: Alfredo Ledezma Melendez [mailto:alfredo.ledezma@mail.telcel.com]
Sent: 31 March 2005 22:29
To: pete.raleigh@lwwcm.com
Subject: RE: [PortletFileUpload] class compiling error

I think the problem is the classpath value. Check that you have tools.jar
and servlet.jar in it.

Regards,
____________________________________________
Alfredo Ledezma Melendez.
Costumer Record Management
Consultor Externo de Sistemas de Atencion a Clientes RadioMovil DIPSA, S. A.
de C. V.
Ejercito Nacional No. 488, Col. Anahuac, C.P. 11570 Mexico D.F.

-----Original Message-----
From: Pete Raleigh [mailto:pete.raleigh@lwwcm.com]
Sent: Thursday, March 31, 2005 2:09 PM
To: commons-user@jakarta.apache.org
Subject: [PortletFileUpload] class compiling error

I would appreciate some assistance in creating a JSR 168 compliant File
Upload Portlet. I have downloaded the 1.1-dev JAR from the commons website
(Nightly build) but seem to be having problems compiling.

My (trimmed) code is as follows:
...
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.portlet.PortletFileUpload;
...
private String processUpload(ActionRequest request, ActionResponse response)
{
        String txt = "";

        File tmpDir = new File("D:\\Temp\\Upload");
        DiskFileItemFactory dfif = new DiskFileItemFactory(10240, tmpDir);
        ...
        PortletFileUpload pfu = new PortletFileUpload(dfif);
        ...
        try
        {
                List fileItems = pfu.parseRequest(request);
                Iterator iter = fileItems.iterator();

                while (iter.hasNext())
                {
                        FileItem item = (FileItem)iter.next();
                        if (item.isFormField())
                        {
                                // Input text field
                                txt += "FIELD NAME: " + item.getFieldName +
"<br>";
                                txt += "VALUE: " + item.getString() +
"<br><br>";
                        } else {
                                // Uploaded file
                                txt += "FIELD NAME: " + item.getFieldName()
+ "<br>";
                                txt += "FILE SIZE: " + item.getSize() +
"<br><br>";
                        }
                }

        } catch (FileUploadException fue) {
                txt += "File Upload Exception: " + fue + "<br>";
        } catch (Exception e) {
                txt += "Exception: " + e + "<br>";
        }
        ...
}
...

The error message I receive is:
com\lcltd\raleigh\jsr168\WCMTools.java:139: cannot access
javax.servlet.http.HttpServletRequest
file javax\servlet\http\HttpServletRequest.class not found
                                List fileItems = pfu.parseRequest(request);
                                                    ^
1 error

I have struggled to find what I am doing wrong and have seen plenty of
references to the HttpServletRequest version (1.0) on Google, but nothing
for a Portlet code example version. What have I missed? :) Do I need to
write additional code for one of these classes - is this class and other
classes in the package unfinished? Does anyone have any example (working)
snippets?

Any help you could provide would be greatly appreciated.

Cheers, Pete.






---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org