portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiwanka Wimalasuriya" <thiwa...@srilogic.com>
Subject uploading files from a jsr168 portlet
Date Fri, 19 Nov 2004 04:54:05 GMT
dear all,

i'm trying to upload a file from a jsr168 portlet. but i'm unable to save the uploaded file.

the jsp in which i upload the file is below


<%@ page import="com.srilogic.portal.portlets.jsr168.example.PersonalizationPortlet" %>

RenderRequest pReq = (RenderRequest)request.getAttribute("javax.portlet.request");
RenderResponse rRes = (RenderResponse)request.getAttribute("javax.portlet.response");
PortletPreferences pref = pReq.getPreferences();
PortletURL actionURL = rRes.createActionURL();

<FORM METHOD="POST" ACTION="<%=actionURL.toString()%>" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="myFile" ID="myFile">
<INPUT TYPE="SUBMIT" NAME="<%=PersonalizationPortlet.CHANGE_IMAGE%>" VALUE="changeImage">


this is the way i tryied to get the uploaded file from the portlet class. the below is the
relavent part of my "PersonalizationPortlet.java"

 public void processAction(
  ActionRequest request,
  ActionResponse actionResponse)
  throws PortletException, IOException {

   //lets try to write the file some where

   InputStream in = request.getPortletInputStream();
   OutputStream os = new FileOutputStream("c:\\demo.out");

      int i = in.read();
   while (i != -1) {
      i = in.read();



this will save a emply file to c:\demo.out what ever file i uplod from the jsp.

any help please

kind regards

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message