|
|
|
|
@ -12,6 +12,8 @@ import java.util.*;
|
|
|
|
|
import javax.servlet.*;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.fileupload.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author psantos
|
|
|
|
|
@ -31,13 +33,55 @@ public class RecruitServlet extends MailerServlet
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public void doPost( HttpServletRequest req, HttpServletResponse res )
|
|
|
|
|
throws IOException
|
|
|
|
|
throws IOException
|
|
|
|
|
{
|
|
|
|
|
Hashtable parameters;
|
|
|
|
|
String fileName = "";
|
|
|
|
|
byte file[] = new byte[0];
|
|
|
|
|
boolean isMultipart = FileUpload.isMultipartContent( req );
|
|
|
|
|
|
|
|
|
|
ServletOutputStream out = res.getOutputStream();
|
|
|
|
|
res.setContentType( "text/html" );
|
|
|
|
|
|
|
|
|
|
if( isMultipart )
|
|
|
|
|
{
|
|
|
|
|
parameters = new Hashtable();
|
|
|
|
|
DiskFileUpload upload = new DiskFileUpload();
|
|
|
|
|
upload.setSizeThreshold(1000000);
|
|
|
|
|
upload.setSizeMax(1000000);
|
|
|
|
|
List items;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
items = upload.parseRequest(req);
|
|
|
|
|
}
|
|
|
|
|
catch( FileUploadException ex )
|
|
|
|
|
{
|
|
|
|
|
out.println( showResultPage( false, "mail/pedido_enviado.html", "mail/pedido_nao_enviado.html" ) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Iterator iter = items.iterator();
|
|
|
|
|
while( iter.hasNext() )
|
|
|
|
|
{
|
|
|
|
|
FileItem item = (FileItem) iter.next();
|
|
|
|
|
|
|
|
|
|
Hashtable parameters = parseParameters( new Hashtable( req.getParameterMap() ) );
|
|
|
|
|
|
|
|
|
|
if (item.isFormField())
|
|
|
|
|
{
|
|
|
|
|
String name = item.getFieldName();
|
|
|
|
|
String value = item.getString();
|
|
|
|
|
parameters.put( name, value );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String fieldName = item.getFieldName();
|
|
|
|
|
fileName = item.getName();
|
|
|
|
|
file = item.get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
parameters = parseParameters( new Hashtable( req.getParameterMap() ) );
|
|
|
|
|
}
|
|
|
|
|
String content = createContent( parameters, FORM_FIELDS, "mail/envio_cv.txt" );
|
|
|
|
|
|
|
|
|
|
String from = ( String ) parameters.get( REC_EMAIL );
|
|
|
|
|
@ -49,9 +93,18 @@ public class RecruitServlet extends MailerServlet
|
|
|
|
|
String destination = email;
|
|
|
|
|
String subject = "Envio de CV através do site www.siprp.pt";
|
|
|
|
|
// manda mail
|
|
|
|
|
boolean success = sendMail( from, destination, subject, content, false );
|
|
|
|
|
boolean success;
|
|
|
|
|
if( isMultipart )
|
|
|
|
|
{
|
|
|
|
|
success = sendMail( from, destination, subject, content, false, fileName, file );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
success = sendMail( from, destination, subject, content, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mostra pagina correspondente
|
|
|
|
|
|
|
|
|
|
out.println( showResultPage( success, "mail/pedido_enviado.html", "mail/pedido_nao_enviado.html" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|