|
Hi,
I�m developing an IMAP webmail client. I�m using
JavaMail API and JSPs. Now I�m trying to attach some files to the messages
but I can�t make the attachments because the mail session is lost
when it returns back from the servlet which uploads the files to the
server. I�ve tried sendRedirect and requestDispatcher in different ways but
without any positive result.
Can anyone help me? Thanks in advance.
This is the code for uploading the file and return
back to the new message jsp:
<PRE>
public void doPost(HttpServletRequest
request, HttpServletResponse response) throws ServletException, IOException
{
// Variables int count=0; SmartUpload mySmartUpload = new SmartUpload(); try { // Initialization mySmartUpload.initialize(config,request,response); // Upload mySmartUpload.upload(); // Save the file with the original name // in a virtual path of the web server HttpSession session =
request.getSession();
WebMailSession wbSession = (WebMailSession)session.getAttribute("wbSession"); count = mySmartUpload.save(wbSession.getFileLocation()); // More than 1 file attached String files=mySmartUpload.getRequest().getParameter("attachFile"); String url = wbSession.getFullJspLocation() + "/webmailNewMail.jsp" + "?to=" + mySmartUpload.getRequest().getParameter( "to" ) + "&attachFile=" + wbSession.getFullFileLocation() + "/"+ mySmartUpload.getFiles().getFile(0).getFileName() + ";" + files; response.sendRedirect(response.encodeRedirectURL(url));
} catch (Exception
e){
System.out.println("Unable to upload the file"); e.printStackTrace(); } } </PRE>
|
