It has always been a topic of discussion about file uploading in portlet specially with JPDK portlet on Oracle Portal server.
I also faced some technical challenges while working with this but now come up with a solution and wants to share with portal world using this article.
You will find numerous post on OTN (Oracle Technology Network) regarding File upload in Portlet technology.
So finally I though about why not to write an article on my blog for the same.
And now...Here we go.......
1. Create a portlet application from your JDeveloper and just write a new servlet into any of your package. This servlet will be doing the actual file uploading functionality.
2. Make a entry for this servlet in your web.xml.
Sample code for the servlet entry in web.xml :-
<servlet>
<servlet-name>UploadFile</servlet-name>
<servlet-class>com.util.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadFile</servlet-name>
<url-pattern>FileUploadServlet</url-pattern>
</servlet-mapping>
3. Let us say you will be having two JSP one is MyProfile.jsp and other is FileUpload.jsp. The FileUpload.jsp will be opened in a pop up window using window.open(<pass required parameters> ) once you click on a link from MyProfile.jsp.
(Note:- off course you might be having other Business and DB related classes and some other JSP also)
4. In the pop up window OR FileUpload.jsp , use the following as your form tag entry
<form method="post" action="<%=request.getContextPath()%>/FileUploadServlet" name="fileuploadform" enctype="multipart/form-data">
5. Once done with development and configuration , deploy your portlet application from the JDeveloper.
You can use application server connection from within your JDeveloper for deployment of your Portlet Application.
Let us understand complete scenario in a more practical way
Let us say you are creating a Matrimonial Portlet , where user will be entering his profile detail and will also upload his photograph.
Matrimonial Portlet must be having these minimum files as follows:
Two Java files , MatrimonialPortlet.java , FileUploadServlet.java and Two JSP files , UserProfile.jsp and FileUpload.jsp.
Again , some other files might be there for your DB and Business related operations.
Now the Functional approach will be like this
1. From MatrimonialPortlet.java , the UserProfile.jsp will be rendered. In this jsp user will enter his profile detail and at the end he will upload his photograph.
2. It means some where (On some link )on this UserProfile.jsp , you will call window.open(<pass required parameters> ) , which will result in opening FileUpload.jsp in a pop up window and this is the jsp where user will upload his photograph.
3. Once the photograph is uploaded , pop up window will be closed and user will come back to UserProfile.jsp and finally press the submit button for submitting his complete profile detail.
I hope , this article will help you to understand about File Uploading in JPDK portlet for Oracle Portal Server.
You can have a look on the thread called File Upload function in Portlet on OTN for the same.
Feel free to post your comment if you have any queries.